Question

I have an application where I would like to use an FBO to display an image of a QuickTime movie. I'm totally new to FBOs and only got a little bit of knowledge on OpenGL. I got problems understanding the FBO paradigm with binding textures and stuff and I'm hoping you guys could help.

To get the movie's current image, I'm using

QTVisualContextCopyImageForTime(theContext, NULL, NULL, &currentFrameTex); where currentFrameTex is a CVImageBufferRef.

For setting up the FBO, all I'm doing is:

glGenFramebuffersEXT(1, &idFrameBuf);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, idFrameBuf);

I'm using the following code to draw the image:

// 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);

I'm just getting a black image and I don't know what I'm doing wrong. More information can be provided if necessary. Thanks in advance!

Was it helpful?

Solution

Please see http://www.opengl.org/wiki/Framebuffer_Object . FBO allows you to render graphics to offscreen buffer and then process it. Your code overwrites the texture provided by currentFrameTex, which does not make much sense. Once you call glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, idFrameBuf) with non zero idFrameBuf then all graphics is drawn to this FBO and nothing to the screen.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top