[Mesa-dev] Question about texture copy with Mesa

Kenneth Graunke kenneth at whitecape.org
Sat Feb 19 10:33:48 PST 2011


On Friday, February 18, 2011 11:08:40 AM Alexis Hétu wrote:
> Hi all,
> 
>   I have a small question : I'd like to feed the already rendered result of
> my scene (which is "on screen" right now) into a texture sampler for the
> rendering of another object. I think this could be achieved by doing
> something like glReadPixels and then re-uploading that as a texture, but
> this seems very inefficient to me. It there a better way of doing this ? Is
> there a proper "MESA" way of doing this ?
> 
> Thanks

The typical way to achieve this is to change your program to render the scene 
into a FBO (framebuffer object) rather than to the screen.  FBOs can be backed 
by textures, allowing you to easily sample the results.  Or, if you don't need 
to sample (say, the depth buffer), you can also use a renderbuffer.

To get the scene on screen again, you can either use glBlitFramebuffer (the 
screen is framebuffer 0), or just draw a full-screen quad with a simple shader 
that samples the FBO's color texture.

Here's a short tutorial on FBOs:
http://www.gamedev.net/page/resources/_//feature/fprogramming/opengl-frame-
buffer-object-101-r2331

Good luck!


More information about the mesa-dev mailing list