【发布时间】:2013-02-01 10:15:00
【问题描述】:
我有一个应用程序,我想使用 FBO 来显示 QuickTime 电影的图像。 我对 FBO 完全陌生,只对 OpenGL 有一点了解。 我在理解 FBO 范式与绑定纹理和东西时遇到了问题,我希望你们能提供帮助。
为了获取电影的当前图像,我正在使用
QTVisualContextCopyImageForTime(theContext, 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);
我只是得到一个黑色的图像,我不知道我做错了什么。 如有必要,可以提供更多信息。提前致谢!
【问题讨论】:
标签: macos opengl quicktime fbo core-video