首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CVPixelBuffer到FBO

CVPixelBuffer到FBO
EN

Stack Overflow用户
提问于 2013-02-16 22:58:09
回答 1查看 903关注 0票数 0

我有一个应用程序,我想使用一个FBO来显示一个QuickTime电影的图像。我对OpenGL完全是个新手,对FBO只有一点点的了解。我在理解FBO范例和绑定纹理之类的东西时遇到了问题,我希望你们能提供帮助。

为了获得电影的当前图像,我使用

QTVisualContextCopyImageForTime(theContext, NULL, NULL, &currentFrameTex);,其中currentFrameTex是CVImageBufferRef。

为了设置FBO,我要做的就是:

代码语言:javascript
复制
glGenFramebuffersEXT(1, &idFrameBuf);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, idFrameBuf);

我使用以下代码来绘制图像:

代码语言:javascript
复制
// 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);

我只是得到了一个黑色的图像,我不知道我做错了什么。如有必要,可以提供更多信息。提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-17 03:58:25

请参阅http://www.opengl.org/wiki/Framebuffer_Object。FBO允许您将图形渲染到屏幕外缓冲区,然后对其进行处理。您的代码覆盖了currentFrameTex提供的纹理,这没有多大意义。一旦你使用非零fbo调用glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,idFrameBuf),那么所有的图形都会被绘制到这个idFrameBuf上,而不会被绘制到屏幕上。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14911626

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档