Graphics Reference
In-Depth Information
Example 12-2
Render to Texture (continued)
//
// The fragment shader uses the texture coordinate to sample
// the texture and uses this as the per-fragment color value.
set_screen_shader_and_uniforms ( );
draw_screen_quad ( );
}
// clean up
glDeleteRenderbuffers ( l, &depthRenderbuffer );
glDeleteFramebuffers ( l, &framebuffer);
glDeleteTextures ( l, &texture );
Figure 12-2
Render to Color Texture
In Example 12-2, we create the framebuffer , texture , and
depthRenderbuffer objects using the appropriate glGen*** commands.
The framebuffer object uses a color attachment that is a texture
object ( texture ) and a depth attachment that is a renderbuffer object
( depthRenderbuffer ).
Before we create these objects, we query the maximum renderbuffer size
( GL_MAX_RENDERBUFFER_SIZE ) to verify that the maximum renderbuffer
size supported by the implementation is less than or equal to the width
and height of texture that will be used as a color attachment. This step
ensures that we can create a depth renderbuffer successfully and use it as
the depth attachment in framebuffer .
 
Search WWH ::




Custom Search