PDA

View Full Version : Render buffer to texture



Rakehell
10-15-2013, 08:52 PM
I'm using glFramebufferTexture2D() to render a buffer to a texture, but that causes it not to display on the screen. How can I write to the texture and to the screen at the same time?

GClements
10-15-2013, 08:56 PM
I'm using glFramebufferTexture2D() to render a buffer to a texture, but that causes it not to display on the screen. How can I write to the texture and to the screen at the same time?

You can't. You render to the texture, then render (or blit) the texture to the screen afterwards. Or render to the texture then render to the screen afterwards.

Rakehell
10-15-2013, 10:25 PM
You can't. You render to the texture, then render (or blit) the texture to the screen afterwards.

How do you do that? Right now I'm just making a copy of the texture.

Dark Photon
10-16-2013, 05:32 AM
How do you do that? Right now I'm just making a copy of the texture.

glBlitFramebuffer(). See this (http://www.opengl.org/wiki/Framebuffer#Blitting). Note that you can't always take this approach depending on the format differences between your texture and the system framebuffer and/or your needs for resizing the texture in the blit.

Or as GClements said, you can just render the texture to the screen in the normal way you render with textures. For instance, draw a textured quad.