glBlitFramebufferEXT ??

Started by
2 comments, last by gold 17 years, 1 month ago
Can someone show me sample working code for this extension. I cant seem to get it to work. I wanna render a scene with a certain dimension and then overlay it on another render. Is this the best way to do this or is there a better way? the Sample code from openGL.org doesnt work, it returns a GL_ENUM error. If I replace the READ_FRAMEBUFFER_EXT / DRAW_FRAMEBUFFER_EXT with default FRAMEBUFFER_EXT, no error occurs but either does blit. http://www.opengl.org/registry/specs/EXT/framebuffer_blit.txt I guess I want to do something similar to Direct3Ds StretchRect function. Sample Code from openGL.org /* Render to framebuffer object 2 */ BindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 2); RenderScene(); /* Blit contents of color buffer, depth buffer and stencil buffer * from framebuffer object 2 to framebuffer object 1 */ BindFramebufferEXT(READ_FRAMEBUFFER_EXT, 2); BindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 1); BlitFramebufferEXT(0, 0, 640, 480, 0, 0, 640, 480, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); /* Blit color buffer from framebuffer object 1 to framebuffer * object 3 with a 2X zoom and linear filtering */ BindFramebufferEXT(READ_FRAMEBUFFER_EXT, 1); BindFramebufferEXT(DRAW_FRAMEBUFFER_EXT, 3); BlitFramebufferEXT(0, 0, 640, 480, 0, 0, 1280, 960, GL_COLOR_BUFFER_BIT, GL_LINEAR); Thanks.
Advertisement
So is there another technique for copying rects of
one framebuffer to another?
Stupid question, but did you check whether your card supports the GL_EXT_framebuffer_blit extension?
There are not many other reasons why the driver could return an ENUM error.

If you really need to copy the stencil and depth buffer (so you can't use the most obvious method with a textures fullscreen quad), another alternative would be to use pixel buffer objects.
When a PBO is bound, the driver is able to execute calls to glReadPixels and glDrawPixels without a system memory copy. I don't know if current drivers would do this, but it may be worth a try.
Your code looks right, from a quick glance. What card/driver are you using? Did you in fact verify that the extension is supported?

This topic is closed to new replies.

Advertisement