如何将OpenGL外部纹理(gl_texture_external_oes)复制到framebuffer
我需要将纹理复制到Framebuffer,然后使用GlreadPixels读取它,然后将输出保存到缓冲区中。主要目标是将范围的输入帧转储到文件中。我当前的代码给我GLX506错误。
int[] frame = new int[1];
int[] mainFrame = new int[1];
glGetIntegerv(GLES32.GL_FRAMEBUFFER_BINDING, mainFrame,0);
GLES32.glGenFramebuffers(1,frame,0);
GlUtil.checkGlError("glGenFramebufferOES");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, frame[0]);
GlUtil.checkGlError("glBindFramebufferOES");
GLES11Ext.glFramebufferTexture2DOES(GLES11Ext.GL_FRAMEBUFFER_OES,GLES11Ext.GL_COLOR_ATTACHMENT0_OES, GLES32.GL_TEXTURE_2D, texture,0);
GlUtil.checkGlError("glFramebufferTexture2DOES");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, frame[0]);
GlUtil.checkGlError("glBindFramebufferOES");
GLES32.glViewport(0, 0, width, height);
GlUtil.checkGlError("glViewport");
ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 4);
GLES32.glReadPixels(0, 0, width, height, GLES32.GL_RGBA,GLES32.GL_UNSIGNED_BYTE, buffer);
GlUtil.checkGlError("glReadPixels");
File file = new File("/sdcard/Movies/frames/input_"+mediaTime+".rgba");
try {
FileOutputStream fos = new FileOutputStream(file.toString());
FileChannel fch = fos.getChannel();
fch.write(buffer);
fch.close();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.d(TAG, "Saved input frame : Dimensions : " + width + "x" + height + " Frame saved as '" + file + "'");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, mainFrame[0]);
GLES32.glViewport(0, 0, mWindowSurface.getWidth(), mWindowSurface.getHeight());
I need to copy the texture to a framebuffer and then read it using GlReadPixels and save the output to a buffer. The main goal is to dump the input frames of exoplayer into a file. My current code gives me glx506 error.
int[] frame = new int[1];
int[] mainFrame = new int[1];
glGetIntegerv(GLES32.GL_FRAMEBUFFER_BINDING, mainFrame,0);
GLES32.glGenFramebuffers(1,frame,0);
GlUtil.checkGlError("glGenFramebufferOES");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, frame[0]);
GlUtil.checkGlError("glBindFramebufferOES");
GLES11Ext.glFramebufferTexture2DOES(GLES11Ext.GL_FRAMEBUFFER_OES,GLES11Ext.GL_COLOR_ATTACHMENT0_OES, GLES32.GL_TEXTURE_2D, texture,0);
GlUtil.checkGlError("glFramebufferTexture2DOES");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, frame[0]);
GlUtil.checkGlError("glBindFramebufferOES");
GLES32.glViewport(0, 0, width, height);
GlUtil.checkGlError("glViewport");
ByteBuffer buffer = ByteBuffer.allocateDirect(width * height * 4);
GLES32.glReadPixels(0, 0, width, height, GLES32.GL_RGBA,GLES32.GL_UNSIGNED_BYTE, buffer);
GlUtil.checkGlError("glReadPixels");
File file = new File("/sdcard/Movies/frames/input_"+mediaTime+".rgba");
try {
FileOutputStream fos = new FileOutputStream(file.toString());
FileChannel fch = fos.getChannel();
fch.write(buffer);
fch.close();
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.d(TAG, "Saved input frame : Dimensions : " + width + "x" + height + " Frame saved as '" + file + "'");
GLES11Ext.glBindFramebufferOES(GLES11Ext.GL_FRAMEBUFFER_OES, mainFrame[0]);
GLES32.glViewport(0, 0, mWindowSurface.getWidth(), mWindowSurface.getHeight());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论