1.创建framebuffer
GLES20.glGenFramebuffers(1,framebuffer,0);
2.创建纹理
//初始化纹理,一个绑定fbo
GLES20.glGenTextures(textur.length, textur, 0); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textur[0]); GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGB,
1000, 1000,
0, GLES20.GL_RGB,
GLES20.GL_UNSIGNED_BYTE, null);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
3.绑定纹理
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,textur[0]);
4.绑定framebuffer
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, framebuffer[0]);
5.framebuffer绑定纹理
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0,
GLES20.GL_TEXTURE_2D, textur[0], 0);
6.绘制,与其他的绘制一样
super.render();
7.解绑framebuffer
GLES20.glBindFramebuffer(GLES20.GL_FRAMEBUFFER, 0);
8.解绑纹理
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,0);
9.绘制framebuffer中的东西,抛开前面,现在绘制纹理,上面创建的texture
网友评论