我有一个应用程序,我想使用一个FBO来显示一个QuickTime电影的图像。我对OpenGL完全是个新手,对FBO只有一点点的了解。我在理解FBO范例和绑定纹理之类的东西时遇到了问题,我希望你们能提供帮助。
为了获得电影的当前图像,我使用
QTVisualContextCopyImageForTime(theContext, NULL, NULL, ¤tFrameTex);,其中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);我只是得到了一个黑色的图像,我不知道我做错了什么。如有必要,可以提供更多信息。提前感谢!
发布于 2013-02-17 03:58:25
请参阅http://www.opengl.org/wiki/Framebuffer_Object。FBO允许您将图形渲染到屏幕外缓冲区,然后对其进行处理。您的代码覆盖了currentFrameTex提供的纹理,这没有多大意义。一旦你使用非零fbo调用glBindFramebufferEXT(GL_FRAMEBUFFER_EXT,idFrameBuf),那么所有的图形都会被绘制到这个idFrameBuf上,而不会被绘制到屏幕上。
https://stackoverflow.com/questions/14911626
复制相似问题