Пример #1
0
//--------------------------------------------------------------------------------------
// Name: Render()
// Desc: 
//--------------------------------------------------------------------------------------
VOID CSample::Render()
{
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

    RenderShadowMapToFBO();
    RenderLightingToFBO();
	RenderBlendedLightingAndShadowMap();

    if( m_bShowShadowMap )
    {
		// must turn off texture comparison, otherwise rendering the texture
		//	to screen will be wrong
		glBindTexture( GL_TEXTURE_2D, m_hShadowMapTexId );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
        glBindTexture( GL_TEXTURE_2D, 0 );
    
        glBindFramebuffer( GL_FRAMEBUFFER, 0 );
        FrmRenderTextureToScreen_GLES( 0, 0, m_nShadowMapFBOTextureWidth, m_nShadowMapFBOTextureHeight, m_hShadowMapTexId,
                                       m_hOverlayShader, m_hOverlayScreenSizeLoc );
    
		// Turn comparison back on for hardware shadow map comparison
		glBindTexture( GL_TEXTURE_2D, m_hShadowMapTexId );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
        glBindTexture( GL_TEXTURE_2D, 0 );
    }

    // Update the timer
    m_Timer.MarkFrame();

    // Render the user interface
    m_UserInterface.Render( m_Timer.GetFrameRate() );
}
//--------------------------------------------------------------------------------------
// Name: FrmRenderTextureToScreen()
// Desc: Helper function to render a texture in screenspace.
//--------------------------------------------------------------------------------------
VOID FrmRenderTextureToScreen_GLES( FLOAT32 sx, FLOAT32 sy, FLOAT32 fScale, 
                                    CFrmTexture* pTexture,
                                    INT32 hShaderProgram, INT32 hScreenSizeLoc )
{
    FrmRenderTextureToScreen_GLES( sx, sy, 
                                   fScale * pTexture->m_nWidth, 
                                   fScale * pTexture->m_nHeight, 
                                   pTexture->m_hTextureHandle, 
                                   hShaderProgram, hScreenSizeLoc );
}