渲染相机图片到纹理

时间:2012-12-17 11:34:42

标签: android

有没有办法将相机图片绑定到着色器?

我通过以下方式设置了相机预览:

// Create shader and GL program
_texture = new SurfaceTexture( _texName );
_camera = Camera.open();
_camera.setPreviewTexture( texture );
_camera.startPreview(); // What does start preview do internally?

当有新照片可用时,我会这样做:

_texture.updateTexImage(); // Should bind to GL_TEXTURE_EXTERNAL_OS
GLES20.glViewport( 0, 0, _surfaceWidth, _surfaceHeight );
GLES20.glBindFramebuffer( GLES20.GL_FRAMEBUFFER, _framebuffers[0] );
GLES20.glFramebufferTexture2D( GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GL_TEXTURE_EXTERNAL_OES, _texName, 0);

P.S。原始代码包含错误检查

0 个答案:

没有答案