Graphics Reference
In-Depth Information
Figure 9.12. Two views of a rotating teapot on a rotating plane.
The render-to-texture operation uses the framebuffer extension, that is,
GL_framebuffer_object , so you need to be sure this is supported on your
system.
The steps to render an image to a texture involve creating the formal buf-
fers needed for output, creating a texture, and assigning the output buffers to
the texture. You then carry out a set of bindings of properties to the buffers and
texture and render a scene; this scene is then a texture, and you can use it in
rendering another scene. The details are below.
1. You will be changing the display destination. Generate a handle for a
framebuffer object, and generate handles for a (depth) renderbuffer
object and for a texture object. (These will later be atached to the frame-
buffer object.)
2. Bind the framebuffer object to the context.
3. Bind the depth renderbuffer object to the context.
Assign storage atributes to it.
Atach it to the framebufer object.
4. Bind the texture object to the context.
Assign storage atributes to it.
Assign texture parameters to it.
Atach it to the framebufer object.
5. Render as normal.
6. Un-bind the framebuffer object from the context.
Search WWH ::




Custom Search