Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos CVPixelBuffer到FBO_Macos_Opengl_Quicktime_Fbo_Core Video - Fatal编程技术网

Macos CVPixelBuffer到FBO

Macos CVPixelBuffer到FBO,macos,opengl,quicktime,fbo,core-video,Macos,Opengl,Quicktime,Fbo,Core Video,我有一个应用程序,我想使用FBO来显示QuickTime电影的图像。 我是FBOs的新手,对OpenGL只了解一点点。 我在理解FBO的绑定纹理和东西方面遇到了问题,我希望你们能帮上忙 要获取电影的当前图像,我使用 QTVisualContextCopyImageForTime(上下文、NULL、NULL和currentFrameTex) 其中currentFrameTex是一个CVImageBufferRef 为了建立FBO,我所做的就是: glGenFramebuffersEXT(1, &a

我有一个应用程序,我想使用FBO来显示QuickTime电影的图像。 我是FBOs的新手,对OpenGL只了解一点点。 我在理解FBO的绑定纹理和东西方面遇到了问题,我希望你们能帮上忙

要获取电影的当前图像,我使用

QTVisualContextCopyImageForTime(上下文、NULL、NULL和currentFrameTex)
其中
currentFrameTex
是一个CVImageBufferRef

为了建立FBO,我所做的就是:

glGenFramebuffersEXT(1, &idFrameBuf);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, idFrameBuf);
我使用以下代码来绘制图像:

// get the texture target (for example, GL_TEXTURE_2D) of the texture
GLint target = CVOpenGLTextureGetTarget(currentFrameTex);
// get the texture target name of the texture
GLint texID = CVOpenGLTextureGetName(currentFrameTex);

// get the texture coordinates for the part of the image that should be displayed
CVOpenGLTextureGetCleanTexCoords(currentFrameTex,
                                 bottomLeft, bottomRight,
                                 topRight, topLeft);
glBindTexture(target, texID);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

glTexImage2D(target, 0, GL_RGBA8, 256, 256, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, target, texID, 0);
我只是得到一个黑色的图像,我不知道我做错了什么。 如有必要,可提供更多信息。提前谢谢

请看。 FBO允许您将图形渲染到屏幕外缓冲区,然后对其进行处理。 您的代码覆盖了currentFrameTex提供的纹理,这没有多大意义。
使用非零idFrameBuf调用glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,idFrameBuf)后,所有图形都将绘制到此FBO,而屏幕上没有任何图形。

嘿,Maf,感谢您的回答。我在哪里重写某些内容?我需要做什么才能正确绘制纹理?我已经读过那篇文章了,但我遗漏了一些东西。谢谢!渲染纹理时不需要FBO。直接渲染到屏幕上。CVOpenGLTextureGetName(currentFrameTex)返回已包含图像的纹理。使用此纹理绑定调用glTexImage2D会使用新内容和新维度重新分配此纹理,因此您可以释放电影帧。将此新纹理附加到FBO(glFramebufferTexture2D)时,实际上是通过FBO对此纹理进行绘制。如果确实需要FBO,请创建新纹理(glGenTextures)并将其附加到FBO或使用渲染缓冲区(glRenderbufferStorage)​).这将与外部视频硬件一起使用。硬件稍后将使用glReadPixels从FBO读取信息。我需要做什么才能将纹理附加到FBO?很抱歉,我只是不理解它背后的范例。FBO只是一种将东西绘制到不可见内存(纹理或渲染缓冲区)的方法。适合您在这种情况下,我建议先创建渲染缓冲区(),然后创建FBO,然后将RB连接到FBO(
glFramebufferRenderbuffer
​). 在app init上执行一次。一旦你将QT纹理绘制到FBO,你将能够从FBO读取像素并复制到你的硬件。