Java GLES20.glFramebufferTexture2D方法代碼示例- 純淨天空

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

本文整理匯總了Java中android.opengl.GLES20.glFramebufferTexture2D方法的典型用法代碼示例。

如果您正苦於以下問題:Java GLES20.glFramebufferTexture2D方法的具體 ... 當前位置:首頁>>代碼示例>>Java>>正文 本文整理匯總了Java中android.opengl.GLES20.glFramebufferTexture2D方法的典型用法代碼示例。

如果您正苦於以下問題:JavaGLES20.glFramebufferTexture2D方法的具體用法?JavaGLES20.glFramebufferTexture2D怎麽用?JavaGLES20.glFramebufferTexture2D使用的例子?那麽恭喜您,這裏精選的方法代碼示例或許可以為您提供幫助。

您也可以進一步了解該方法所在類android.opengl.GLES20的用法示例。

在下文中一共展示了GLES20.glFramebufferTexture2D方法的11個代碼示例,這些例子默認根據受歡迎程度排序。

您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1:createFrameBuffer ​點讚3 ​ importandroid.opengl.GLES20;//導入方法依賴的package包/類 /** *創建FrameBuffer *@paramhasRenderBuffer是否啟用RenderBuffer *@paramwidth寬度 *@paramheight高度 *@paramtexType類型,一般為{@linkGLES20#GL_TEXTURE_2D} *@paramtexFormat紋理格式,一般為{@linkGLES20#GL_RGBA}、{@linkGLES20#GL_RGB}等 *@paramminParams紋理的縮小過濾參數 *@parammaxParams紋理的放大過濾參數 *@paramwrapS紋理的S環繞參數 *@paramwrapT紋理的W環繞參數 *@return創建結果,0表示成功,其他值為GL錯誤 */ publicintcreateFrameBuffer(booleanhasRenderBuffer,intwidth,intheight,inttexType,inttexFormat, intminParams,intmaxParams,intwrapS,intwrapT){ mFrameTemp=newint[4]; GLES20.glGenFramebuffers(1,mFrameTemp,0); GLES20.glGenTextures(1,mFrameTemp,1); GLES20.glBindTexture(texType,mFrameTemp[1]); GLES20.glTexImage2D(texType,0,texFormat,width,height, 0,texFormat,GLES20.GL_UNSIGNED_BYTE,null); //設置縮小過濾為使用紋理中坐標最接近的一個像素的顏色作為需要繪製的像素顏色 GLES20.glTexParameteri(texType,GLES20.GL_TEXTURE_MIN_FILTER,minParams); //設置放大過濾為使用紋理中坐標最接近的若幹個顏色,通過加權平均算法得到需要繪製的像素顏色 GLES20.glTexParameteri(texType,GLES20.GL_TEXTURE_MAG_FILTER,maxParams); //設置環繞方向S,截取紋理坐標到[1/2n,1-1/2n]。

將導致永遠不會與border融合 GLES20.glTexParameteri(texType,GLES20.GL_TEXTURE_WRAP_S,wrapS); //設置環繞方向T,截取紋理坐標到[1/2n,1-1/2n]。

將導致永遠不會與border融合 GLES20.glTexParameteri(texType,GLES20.GL_TEXTURE_WRAP_T,wrapT); GLES20.glGetIntegerv(GLES20.GL_FRAMEBUFFER_BINDING,mFrameTemp,3); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,mFrameTemp[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, texType,mFrameTemp[1],0); if(hasRenderBuffer){ GLES20.glGenRenderbuffers(1,mFrameTemp,2); GLES20.glBindRenderbuffer(GLES20.GL_RENDERBUFFER,mFrameTemp[2]); GLES20.glRenderbufferStorage(GLES20.GL_RENDERBUFFER,GLES20.GL_DEPTH_COMPONENT16,width,height); GLES20.glFramebufferRenderbuffer(GLES20.GL_FRAMEBUFFER,GLES20.GL_DEPTH_ATTACHMENT,GLES20.GL_RENDERBUFFER,mFrameTemp[2]); } returnGLES20.glGetError(); } 開發者ID:aiyaapp,項目名稱:AAVT,代碼行數:43,代碼來源:FrameBuffer.java 示例2:createFrameBuffer ​點讚3 ​ importandroid.opengl.GLES20;//導入方法依賴的package包/類 publicvoidcreateFrameBuffer(intwidth,intheight,int[]frameBuffer,int[]frameBufferTexture,intframeBufferSize){ for(inti=0;itmpList; if(frameListeners.isEmpty()) return; tmpList=newArrayList<>(frameListeners); frameListeners.clear(); finalfloat[]bitmapMatrix=RendererCommon.multiplyMatrices( RendererCommon.multiplyMatrices(texMatrix, mirror?RendererCommon.horizontalFlipMatrix():RendererCommon.identityMatrix()), RendererCommon.verticalFlipMatrix()); for(FrameListenerAndParamslistenerAndParams:tmpList){ finalintscaledWidth=(int)(listenerAndParams.scale*frame.rotatedWidth()); finalintscaledHeight=(int)(listenerAndParams.scale*frame.rotatedHeight()); if(scaledWidth==0||scaledHeight==0){ listenerAndParams.listener.onFrame(null); continue; } if(bitmapTextureFramebuffer==null){ bitmapTextureFramebuffer=newGlTextureFrameBuffer(GLES20.GL_RGBA); } bitmapTextureFramebuffer.setSize(scaledWidth,scaledHeight); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,bitmapTextureFramebuffer.getFrameBufferId()); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D,bitmapTextureFramebuffer.getTextureId(),0); if(frame.yuvFrame){ listenerAndParams.drawer.drawYuv(yuvTextures,bitmapMatrix,frame.rotatedWidth(), frame.rotatedHeight(),0/*viewportX*/,0/*viewportY*/,scaledWidth,scaledHeight); }else{ listenerAndParams.drawer.drawOes(frame.textureId,bitmapMatrix,frame.rotatedWidth(), frame.rotatedHeight(),0/*viewportX*/,0/*viewportY*/,scaledWidth,scaledHeight); } finalByteBufferbitmapBuffer=ByteBuffer.allocateDirect(scaledWidth*scaledHeight*4); GLES20.glViewport(0,0,scaledWidth,scaledHeight); GLES20.glReadPixels( 0,0,scaledWidth,scaledHeight,GLES20.GL_RGBA,GLES20.GL_UNSIGNED_BYTE,bitmapBuffer); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,0); GlUtil.checkNoGLES2Error("EglRenderer.notifyCallbacks"); finalBitmapbitmap=Bitmap.createBitmap(scaledWidth,scaledHeight,Bitmap.Config.ARGB_8888); bitmap.copyPixelsFromBuffer(bitmapBuffer); listenerAndParams.listener.onFrame(bitmap); } } 開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:54,代碼來源:EglRenderer.java 示例9:drawBlurPass ​點讚2 ​ importandroid.opengl.GLES20;//導入方法依賴的package包/類 privatebooleandrawBlurPass(){ if(showOriginal||blurType==0){ returnfalse; } if(needUpdateBlurTexture){ GLES20.glUseProgram(blurShaderProgram); GLES20.glUniform1i(blurSourceImageHandle,0); GLES20.glEnableVertexAttribArray(blurInputTexCoordHandle); GLES20.glVertexAttribPointer(blurInputTexCoordHandle,2,GLES20.GL_FLOAT,false,8,textureBuffer); GLES20.glEnableVertexAttribArray(blurPositionHandle); GLES20.glVertexAttribPointer(blurPositionHandle,2,GLES20.GL_FLOAT,false,8,vertexInvertBuffer); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,renderFrameBuffer[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,renderTexture[0],0); GLES20.glClear(0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,renderTexture[1]); GLES20.glUniform1f(blurWidthHandle,0.0f); GLES20.glUniform1f(blurHeightHandle,1.0f/renderBufferHeight); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP,0,4); GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,renderFrameBuffer[2]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,renderTexture[2],0); GLES20.glClear(0); GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,renderTexture[0]); GLES20.glUniform1f(blurWidthHandle,1.0f/renderBufferWidth); GLES20.glUniform1f(blurHeightHandle,0.0f); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP,0,4); needUpdateBlurTexture=false; } GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER,renderFrameBuffer[0]); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,GLES20.GL_COLOR_ATTACHMENT0,GLES20.GL_TEXTURE_2D,renderTexture[0],0); GLES20.glClear(0); if(blurType==1){ GLES20.glUseProgram(radialBlurShaderProgram); GLES20.glUniform1i(radialBlurSourceImageHandle,0); GLES20.glUniform1i(radialBlurSourceImage2Handle,1); GLES20.glUniform1f(radialBlurExcludeSizeHandle,blurExcludeSize); GLES20.glUniform1f(radialBlurExcludeBlurSizeHandle,blurExcludeBlurSize); GLES20.glUniform2f(radialBlurExcludePointHandle,blurExcludePoint.x,blurExcludePoint.y); GLES20.glUniform1f(radialBlurAspectRatioHandle,(float)renderBufferHeight/(float)renderBufferWidth); GLES20.glEnableVertexAttribArray(radialBlurInputTexCoordHandle); GLES20.glVertexAttribPointer(radialBlurInputTexCoordHandle,2,GLES20.GL_FLOAT,false,8,textureBuffer); GLES20.glEnableVertexAttribArray(radialBlurPositionHandle); GLES20.glVertexAttribPointer(radialBlurPositionHandle,2,GLES20.GL_FLOAT,false,8,vertexInvertBuffer); }elseif(blurType==2){ GLES20.glUseProgram(linearBlurShaderProgram); GLES20.glUniform1i(linearBlurSourceImageHandle,0); GLES20.glUniform1i(linearBlurSourceImage2Handle,1); GLES20.glUniform1f(linearBlurExcludeSizeHandle,blurExcludeSize); GLES20.glUniform1f(linearBlurExcludeBlurSizeHandle,blurExcludeBlurSize); GLES20.glUniform1f(linearBlurAngleHandle,blurAngle); GLES20.glUniform2f(linearBlurExcludePointHandle,blurExcludePoint.x,blurExcludePoint.y); GLES20.glUniform1f(linearBlurAspectRatioHandle,(float)renderBufferHeight/(float)renderBufferWidth); GLES20.glEnableVertexAttribArray(linearBlurInputTexCoordHandle); GLES20.glVertexAttribPointer(linearBlurInputTexCoordHandle,2,GLES20.GL_FLOAT,false,8,textureBuffer); GLES20.glEnableVertexAttribArray(linearBlurPositionHandle); GLES20.glVertexAttribPointer(linearBlurPositionHandle,2,GLES20.GL_FLOAT,false,8,vertexInvertBuffer); } GLES20.glActiveTexture(GLES20.GL_TEXTURE0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,renderTexture[1]); GLES20.glActiveTexture(GLES20.GL_TEXTURE1); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,renderTexture[2]); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP,0,4); returntrue; } 開發者ID:MLNO,項目名稱:airgram,代碼行數:71,代碼來源:PhotoFilterView.java 示例10:attach ​點讚2 ​ importandroid.opengl.GLES20;//導入方法依賴的package包/類 publicvoidattach(intpoint,Texturetex){ bind(); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,point,GLES20.GL_TEXTURE_2D,tex.id,0); } 開發者ID:G2159687,項目名稱:ESPD,代碼行數:5,代碼來源:Framebuffer.java 示例11:attach ​點讚2 ​ importandroid.opengl.GLES20;//導入方法依賴的package包/類 publicvoidattach(intpoint,Texturetex){ bind(); GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER,point,GLES20.GL_TEXTURE_2D,tex.id,0); } 開發者ID:mango-tree,項目名稱:UNIST-pixel-dungeon,代碼行數:5,代碼來源:Framebuffer.java 注:本文中的android.opengl.GLES20.glFramebufferTexture2D方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

相關方法 GLES20.glBindTexture() GLES20.glGetUniformLocation() GLES20.glEnableVertexAttribArray() GLES20.glVertexAttribPointer() GLES20.glUseProgram() GLES20.glUniformMatrix4fv() GLES20.glActiveTexture() GLES20.glClear() GLES20.glDrawArrays() GLES20.glGetAttribLocation() GLES20.glUniform1i() GLES20.glGenTextures() GLES20.glClearColor() GLES20.glAttachShader() GLES20.glViewport() GLES20.glCreateProgram() GLES20.glTexParameteri() GLES20.glLinkProgram() GLES20.glCompileShader() GLES20.glCreateShader() GLES20.glShaderSource() GLES20.glBindFramebuffer() GLES20.glDeleteShader() GLES20.glDeleteProgram() GLES20.glUniform1f() GLES20.glBindBuffer() GLES20.glDisableVertexAttribArray() GLES20.glEnable() GLES20.glDeleteTextures() GLES20.glGetShaderiv() GLES20.glGetProgramiv() GLES20.glGetError() GLES20.glTexParameterf() GLES20.glDisable() GLES20.glTexImage2D() GLES20.glBlendFunc() GLES20.glDrawElements() GLES20.GL_NO_ERROR GLES20.glUniform4fv() GLES20.glBufferData() GLES20.glFramebufferTexture2D() GLES20.glDeleteFramebuffers() GLES20.glGenFramebuffers() GLES20.GL_TRUE GLES20.glGenBuffers() GLES20.glCheckFramebufferStatus() GLES20.GL_FRAMEBUFFER_COMPLETE GLES20.glScissor() GLES20.glUniform2f() GLES20.glBindAttribLocation() GLES20.glGetProgramInfoLog() GLES20.glUniform2fv() GLES20.GL_FALSE GLES20.glUniform4f() GLES20.glUniform3f() GLES20.glDeleteBuffers() GLES20.glFlush() GLES20.glGetString() GLES20.glReadPixels() GLES20.glUniform3fv() GLES20.glLineWidth() GLES20.glFinish() GLES20.glUniform1fv() GLES20.glGenRenderbuffers() GLES20.GL_TEXTURE_2D GLES20.glPixelStorei() GLES20.glValidateProgram() GLES20.glGetShaderInfoLog() GLES20.glDeleteRenderbuffers() GLES20.glGetIntegerv() GLES20.glGenerateMipmap() GLES20.glRenderbufferStorage() GLES20.glBindRenderbuffer() GLES20.glFramebufferRenderbuffer() GLES20.glUniformMatrix3fv() GLES20.glDepthMask() GLES20.glTexSubImage2D() GLES20.glFrontFace() GLES20.GL_RGBA GLES20.glCullFace() GLES20.glDepthFunc() GLES20.glVertexAttrib3f() GLES20.GL_UNSIGNED_BYTE GLES20.GL_TEXTURE0 GLES20.glBufferSubData() GLES20.GL_RGB GLES20.GL_TEXTURE1 GLES20.glBlendEquation() GLES20.glDetachShader() GLES20.GL_LUMINANCE GLES20.glIsEnabled() GLES20.GL_TEXTURE6 GLES20.GL_TEXTURE4 GLES20.GL_TEXTURE5



請為這篇文章評分?