Graphics Reference
In-Depth Information
// Tell OpenGL that you are going to render into the color
// planes of the Texture
glFramebufferTexture2D( GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, Texture, 0 );
// see if OpenGL thinks the framebuffer is complete enough to
// use:
GLenum status = glCheckFramebufferStatus( GL_FRAMEBUFFER );
if( status != GL_FRAMEBUFFER_COMPLETE )
fprintf( stderr, “FrameBuffer is not complete.\n” );
The next code group implements the last two points in the list above, and
would typically be found in the Display( ) callback function. The first part of
this code is very familiar modeling code, but it renders the wireframe teapot
into the texture framebuffer. After that is finished, the rendering is returned
to the usual hardware framebuffer. This is the last point in the list above. We
have highlighted two points in the code to remind you that the dimension of
the texture you are creating must be the same as the size you defined, and to
note that framebuffer 0 is the standard hardware buffer.
// render as normal; be sure to set the viewport to match the
// size of the color and depth buffers
glClearColor( 0.0, 0.2, 0.0, 1. );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glEnable( GL_DEPTH_TEST );
glShadeModel( GL_FLAT );
glViewport( 0, 0, sizeX, sizeY );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 90., 1., 0.1, 1000. );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );
gluLookAt( 0., 0., 3., 0., 0., 0., 0., 1., 0. );
glTranslatef( TransXYZ[0], TransXYZ[1], TransXYZ[2] );
glMultMatrixf( RotMatrix );
glScalef( scale, scale, scale );
glColor3f( 1., 1., 1. );
glutWireTeapot( 1. );
Search WWH ::




Custom Search