Render to texture

I’ve downloaded some render to texture demos. It explain only how to render to a black textured quad. Anyone know how to render to a normal textured quad ( with an image applyed on it ) ?

There are loads of demos on my site that uses render to texture. http://esprit.campus.luth.se/~humus/

Why don’t you give him an answer rather than giving him links while the answer is simple? :stuck_out_tongue:

Generate a texture, using glGenTexture() draw your scene to a power of two viewport, bind the texture then copy the data using glCopyTexSubImage() … not sure if this is the exact name of the function though

Hope this helps

Daher, that’s not render-to-texture, that’s render-to-backbuffer-then-copy-to-texture.
So your simple answer was wrong.

The “simple” answer is to do it the same way as the samples that render to the black quad. Only instead of using glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) you just do glClear(GL_DEPTH_BUFFER_BIT) then draw your textured quad (disable depth writes) and then any overlays (that were previously drawn over the black quad).

Basically you just have to remember that it doesn’t matter what you draw to your pbuffer/texture.

And Daher, just giving links promotes a bit of self education instead of the usual “can you give me the answer”.