Render To Texture

Render To Texture 1   Render To Texture 2


This is my first use of pbuffers. It is a simple project which creates a render-to-texture-enabled pbuffer, and a texture object related to it. When rendering, the pbuffer is made the current context, and two wire tori are rendered into it. The window is then made current, and the pbuffer is used to texture a single rectangle. The camera can be moved around this rectangle.

If the SGIS_generate_mipmap extension is supported, it is used to automatically generate mipmaps for the texture each time it is updated, and a LINEAR_MIPMAP_LINEAR filter is used. Otherwise, a LINEAR filter is used.

If anisotropic filtering is supported, the maximum degree of anisotropy is enabled at start-up. The anisotropy level can be altered to show the difference this filtering has on the textured quad.

It is also possible to render a second scene into the pbuffer, a textured teapot instead of the wire torus. This demonstrates rendering using textures in the pbuffer, then using the pbuffer image itself as a texture. The important thing to note here is that the texture object which will use the pbuffer image is part of the window context. The image on the teapot is part of the pbuffer context. It is important to load the image when the pbuffer context is current since in this demo, the two contexts do not share textures.






Using pbuffers for off-screen rendering, by Chris Wynn.

OpenGL Render-to-Texture, by Chris Wynn.

Download: (124 KB)