tests/cuda2.2/sdk/rendercheck_gl.cpp
//////////////////////////////////////////////////////////////////////
//  renderQuad (sourced from FBO, assume the binding has already taken place)
//
//////////////////////////////////////////////////////////////////////
renderQuad (sourced from FBO, assume the binding has already taken place)
renderQuad ( sourced from FBO assume the binding has already taken place )
void CFrameBufferObject::renderQuad(int width, int height, GLenum eTarget)
{
#if 1
    glBindTexture(eTarget, m_fboData.colorTex);
    glGenerateMipmapEXT( GL_TEXTURE_2D );
    glBindTexture(eTarget, 0);
	glClearColor(0.2, 0.2, 0.2, 0.0);
	glClear(GL_COLOR_BUFFER_BIT);
	glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_textureProgram );
	glEnable(GL_FRAGMENT_PROGRAM_ARB);
	glDisable(GL_DEPTH_TEST);
	glBegin(GL_QUADS);
	{
		glVertex2f(0, 0); glTexCoord2f(0, 0);
		glVertex2f(0, 1); glTexCoord2f(1, 0);
		glVertex2f(1, 1); glTexCoord2f(1, 1);
		glVertex2f(1, 0); glTexCoord2f(0, 1);
	}
	glEnd();
    glBindTexture(eTarget, 0);
#else
    glBindTexture(eTarget, m_fboData.colorTex);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glEnable(eTarget);
    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
    glMatrixMode( GL_MODELVIEW);
    glLoadIdentity();
    glViewport(0, 0, width, height);
	if (m_bUseFloat) {
		glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_textureProgram );
		glEnable(GL_FRAGMENT_PROGRAM_ARB);
		glDisable(GL_DEPTH_TEST);
	}
    glBegin(GL_QUADS);
	if (eTarget == GL_TEXTURE_2D) {
		glTexCoord2f(0.0f , 0.0f  ); glVertex3f(-1.0f, -1.0f, 0.5f);
		glTexCoord2f(1.0f , 0.0f  ); glVertex3f( 1.0f, -1.0f, 0.5f);
		glTexCoord2f(1.0f , 1.0f  ); glVertex3f( 1.0f,  1.0f, 0.5f);
		glTexCoord2f(0.0f , 1.0f  ); glVertex3f(-1.0f,  1.0f, 0.5f);
	} else {
		glTexCoord2f(0.0f , 0.0f  ); glVertex3f(-1.0f, -1.0f, 0.5f);
		glTexCoord2f(width, 0.0f  ); glVertex3f( 1.0f, -1.0f, 0.5f);
		glTexCoord2f(width, height); glVertex3f( 1.0f,  1.0f, 0.5f);
		glTexCoord2f(0.0f , height); glVertex3f(-1.0f,  1.0f, 0.5f);
	}
    glEnd();
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glDisable(eTarget);
    glBindTexture(eTarget, 0);
#endif
}
void CFrameBufferObject :: renderQuad ( int width , int height , GLenum eTarget ) { #if 1 glBindTexture ( eTarget , m_fboData . colorTex ) ; glGenerateMipmapEXT ( GL_TEXTURE_2D ) ; glBindTexture ( eTarget , 0 ) ; glClearColor ( 0.2 , 0.2 , 0.2 , 0.0 ) ; glClear ( GL_COLOR_BUFFER_BIT ) ; glBindProgramARB ( GL_FRAGMENT_PROGRAM_ARB , m_textureProgram ) ; glEnable ( GL_FRAGMENT_PROGRAM_ARB ) ; glDisable ( GL_DEPTH_TEST ) ; glBegin ( GL_QUADS ) ; { glVertex2f ( 0 , 0 ) ; glTexCoord2f ( 0 , 0 ) ; glVertex2f ( 0 , 1 ) ; glTexCoord2f ( 1 , 0 ) ; glVertex2f ( 1 , 1 ) ; glTexCoord2f ( 1 , 1 ) ; glVertex2f ( 1 , 0 ) ; glTexCoord2f ( 0 , 1 ) ; } glEnd ( ) ; glBindTexture ( eTarget , 0 ) ; #else glBindTexture ( eTarget , m_fboData . colorTex ) ; glDisable ( GL_DEPTH_TEST ) ; glDisable ( GL_LIGHTING ) ; glEnable ( eTarget ) ; glTexEnvf ( GL_TEXTURE_ENV , GL_TEXTURE_ENV_MODE , GL_REPLACE ) ; glMatrixMode ( GL_PROJECTION ) ; glPushMatrix ( ) ; glLoadIdentity ( ) ; glOrtho ( -1.0 , 1.0 , -1.0 , 1.0 , -1.0 , 1.0 ) ; glMatrixMode ( GL_MODELVIEW ) ; glLoadIdentity ( ) ; glViewport ( 0 , 0 , width , height ) ; if ( m_bUseFloat ) { glBindProgramARB ( GL_FRAGMENT_PROGRAM_ARB , m_textureProgram ) ; glEnable ( GL_FRAGMENT_PROGRAM_ARB ) ; glDisable ( GL_DEPTH_TEST ) ; } glBegin ( GL_QUADS ) ; if ( eTarget == GL_TEXTURE_2D ) { glTexCoord2f ( 0.0f , 0.0f ) ; glVertex3f ( -1.0f , -1.0f , 0.5f ) ; glTexCoord2f ( 1.0f , 0.0f ) ; glVertex3f ( 1.0f , -1.0f , 0.5f ) ; glTexCoord2f ( 1.0f , 1.0f ) ; glVertex3f ( 1.0f , 1.0f , 0.5f ) ; glTexCoord2f ( 0.0f , 1.0f ) ; glVertex3f ( -1.0f , 1.0f , 0.5f ) ; } else { glTexCoord2f ( 0.0f , 0.0f ) ; glVertex3f ( -1.0f , -1.0f , 0.5f ) ; glTexCoord2f ( width , 0.0f ) ; glVertex3f ( 1.0f , -1.0f , 0.5f ) ; glTexCoord2f ( width , height ) ; glVertex3f ( 1.0f , 1.0f , 0.5f ) ; glTexCoord2f ( 0.0f , height ) ; glVertex3f ( -1.0f , 1.0f , 0.5f ) ; } glEnd ( ) ; glMatrixMode ( GL_PROJECTION ) ; glPopMatrix ( ) ; glDisable ( eTarget ) ; glBindTexture ( eTarget , 0 ) ; #endif }
renderQuad (sourced from FBO, assume the binding has already taken place)
renderQuad ( sourced from FBO assume the binding has already taken place )
// Bind the FBO texture for the display path // now render to the full screen using this texture // Release the FBO texture (finished rendering) // Bind the FBO texture for the display path // render a screen sized quad // fragment program is required to display floating point texture // Release the FBO texture (finished rendering)