android.opengl.GLES20.glFramebufferRenderbuffer java ...

文章推薦指數: 80 %
投票人數:10人

public void glFramebufferRenderbufferEXT(int param1, int param2, int param3, int param4) { GLES20.glFramebufferRenderbuffer(param1, param2, param3, param4); HowtouseglFramebufferRenderbuffermethodinandroid.opengl.GLES20BestJavacodesnippetsusingandroid.opengl.GLES20.glFramebufferRenderbuffer(Showingtop20resultsoutof315)publicvoidglFramebufferRenderbufferEXT(intparam1,intparam2,intparam3,intparam4){ GLES20.glFramebufferRenderbuffer(param1,param2,param3,param4); } publicvoidbind(){ GLES20.glViewport(0,0,width,height); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,frameBufferId); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,texId,0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,renderBufferId); } GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,bufferHandles[0]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,mWidth,mHeight); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,bufferHandles[0]); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER, GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,mRboId[0]); @Override publicvoidonDrawFrame(GL10gl){ if(mBitmap!=null&&!mBitmap.isRecycled()){ createEnvi(); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fFrame[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,fTexture[1],0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glViewport(0,0,mBitmap.getWidth(),mBitmap.getHeight()); mFilter.setTextureId(fTexture[0]); mFilter.draw(); GLES20.glReadPixels(0,0,mBitmap.getWidth(),mBitmap.getHeight(),GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE,mBuffer); if(mCallback!=null){ mCallback.onCall(mBuffer); } deleteEnvi(); mBitmap.recycle(); } } publicvoidcreateEnvi(){ GLES20.glGenFramebuffers(1,fFrame,0); GLES20.glGenRenderbuffers(1,fRender,0); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16, mBitmap.getWidth(),mBitmap.getHeight()); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,0); GLES20.glGenTextures(2,fTexture,0); for(inti=0;i<2;i++){ GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,fTexture[i]); if(i==0){ GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,mBitmap,0); }else{ GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D,0,GLES20.GL_RGBA,mBitmap.getWidth(),mBitmap.getHeight(), 0,GLES20.GL_RGBA,GLES20.GL_UNSIGNED_BYTE,null); } GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE); GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE); } mBuffer=ByteBuffer.allocate(mBitmap.getWidth()*mBitmap.getHeight()*4); } @Override publicvoidglFramebufferRenderbuffer(inttarget,intattachment,intrenderbuffertarget, intrenderbuffer){ GLES20.glFramebufferRenderbuffer(target,attachment,renderbuffertarget,renderbuffer); } @Override publicvoidglFramebufferRenderbuffer(inttarget,intattachment,intrenderbuffertarget, intrenderbuffer){ GLES20.glFramebufferRenderbuffer(target,attachment,renderbuffertarget,renderbuffer); } @Override publicvoidglFramebufferRenderbuffer(inttarget,intattachment,intrenderbuffertarget, intrenderbuffer){ GLES20.glFramebufferRenderbuffer(target,attachment,renderbuffertarget,renderbuffer); } privatebooleancreateFrameBuffer(){ GLES20.glGenFramebuffers(1,fFrame,0); GLES20.glGenRenderbuffers(1,fRender,0); genTextures(); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fFrame[0]); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,width, height); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,fTexture[0],0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); //intstatus=GLES20.glCheckFramebufferStatus(GLES20.GL_FRAMEBUFFER); //if(status==GLES20.GL_FRAMEBUFFER_COMPLETE){ //returntrue; //} unBindFrame(); returnfalse; } @Override publicvoidframebufferRenderbuffer(inttarget,intattachment,intrendbuferfTarget,intrenderbuffer){ GLES20.glFramebufferRenderbuffer(target,attachment,rendbuferfTarget,renderbuffer); } publicvoiddraw(){ updateFilter(); textureIndex=0; if(size>0){ for(AFilterfilter:mFilters){ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fFrame[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,fTexture[textureIndex%2],0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glViewport(0,0,width,height); if(textureIndex==0){ filter.setTextureId(getTextureId()); }else{ filter.setTextureId(fTexture[(textureIndex-1)%2]); } filter.draw(); unBindFrame(); textureIndex++; } } } publicvoidattach(intpoint,Renderbufferbuffer){ bind(); GLES20.glFramebufferRenderbuffer(GLES20.GL_RENDERBUFFER,point,GLES20.GL_TEXTURE_2D,buffer.id()); } publicvoidattach(intpoint,Renderbufferbuffer){ bind(); GLES20.glFramebufferRenderbuffer(GLES20.GL_RENDERBUFFER,point,GLES20.GL_TEXTURE_2D,buffer.id()); } publicvoidbind(){ GLES20.glViewport(0,0,width,height); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,frameBufferId); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,texId,0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,renderBufferId); } privatebooleancreateFrameBuffer(){ GLES20.glGenFramebuffers(1,fFrame,0); GLES20.glGenRenderbuffers(1,fRender,0); genTextures(); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fFrame[0]); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,width, height); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,fTexture[0],0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); unBindFrame(); returnfalse; } @Override protectedvoidonSizeChanged(intwidth,intheight){ if(this.width!=width&&this.height!=height){ this.width=width; this.height=height; mFilter.setSize(width,height); deleteFrameBuffer(); GLES20.glGenFramebuffers(1,fFrame,0); GLES20.glGenRenderbuffers(1,fRender,0); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16, width,height); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,0); EasyGlUtils.genTexturesWithParameter(1,fTexture,0,GLES20.GL_RGBA,width,height); } } privatevoiddeleteFrameBuffer(){ @Override publicvoiddraw(){ booleanb=GLES20.glIsEnabled(GLES20.GL_CULL_FACE); if(b){ GLES20.glDisable(GLES20.GL_CULL_FACE); } GLES20.glViewport(0,0,width,height); EasyGlUtils.bindFrameTexture(fFrame[0],fTexture[0]); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); mFilter.setTextureId(getTextureId()); mFilter.draw(); EasyGlUtils.unBindFrameBuffer(); if(b){ GLES20.glEnable(GLES20.GL_CULL_FACE); } } /** *双Texture,一个输入一个输出,循环往复 */ publicvoiddraw(){ updateFilter(); textureIndex=0; for(BaseFilterfilter:mFilters){ GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fFrame[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,fTexture[textureIndex%2],0); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,fRender[0]); GLES20.glViewport(0,0,width,height); if(textureIndex==0){ filter.setTextureId(getTextureId()); }else{ filter.setTextureId(fTexture[(textureIndex-1)%2]); } filter.draw(); unBindFrame(); textureIndex++; } } height); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,fboId[0]); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT, GLES20.GL_RENDERBUFFER,rboId[0]); android.openglGLES20glFramebufferRenderbufferPopularmethodsofGLES20glGetUniformLocationglEnableVertexAttribArrayglVertexAttribPointerglGetAttribLocationglCreateProgramglCreateShaderglUseProgramglAttachShaderglCompileShaderglLinkProgramglShaderSourceglClearglShaderSource,glClear,glClearColor,glBindTexture,glGenTextures,glGetShaderiv,glViewport,glDeleteShader,glActiveTexture,glDrawArraysPopularinJavaMakinghttppostrequestsusingokhttpcompareTo(BigDecimal)getSupportFragmentManager(FragmentActivity)getOriginalFilename(MultipartFile)Returntheoriginalfilenameintheclient'sfilesystem.Thismaycontainpath informationdependingFileNotFoundException(java.io)Thrownwhenafilespecifiedbyaprogramcannotbefound.Collection(java.util)Collectionistherootofthecollectionhierarchy.Itdefinesoperationson datacollectionsandtHashtable(java.util)Aplug-inreplacementforJDK1.5java.util.Hashtable.Thisversionisbasedon org.cliffc.high_scaleVector(java.util)VectorisanimplementationofList,backedbyanarrayandsynchronized.All optionaloperationsinJPanel(javax.swing)Location(org.springframework.beans.factory.parsing)ClassthatmodelsanarbitrarylocationinaResource.Typicallyusedtotrack thelocationofprobleTop12JupyterNotebookExtensionsProductsSearchforJavacodeSearchforJavaScriptcodeIDEPluginsIntelliJIDEAWebStormVisualStudioAndroidStudioEclipseVisualStudioCodePyCharmSublimeTextPhpStormVimAtomGoLandRubyMineEmacsJupyterNotebookJupyterLabRiderDataGripAppCodeCompanyAboutUsContactUsCareersResourcesFAQBlogTabnineAcademyStudentsTermsofusePrivacypolicyJavaCodeIndexJavascriptCodeIndexGetTabnineforyourIDEnow



請為這篇文章評分?