bool DeferredShadingMSAA::UpdateRenderTargetMode()
{
    // This method can be called before we have a valid size for our render targets.
    // In that case, simply return and wait for a call with valid values.
    if (m_imageWidth == 0 || m_imageHeight == 0)
    {
        return false;
    }

    // Determine what frame buffer mode we need to be in, and if we're not
    // currently in that mode, destroy the current render targets and 
    // initialize the new ones.
    if (m_approach == APPROACH_NOMSAA)
    {
        if (m_currentRTMode != RTMODE_NOMSAA)
        {
            DestroyRenderTargets();
            InitRenderTargets_NoMSAA();
        }
    }
    else if (m_bUsePerSamplePixelShader)
    {
        if (m_currentRTMode != RTMODE_PERSAMPLE)
        {
            DestroyRenderTargets();
            InitRenderTargets_PerSampleShading();
        }
    }
    else
    {
        if (m_currentRTMode != RTMODE_PERPIXEL)
        {
            DestroyRenderTargets();
            InitRenderTargets_PerPixelShading();
        }
    }
    return true;
}
void DeferredShadingMSAA::reshape(int32_t width, int32_t height)
{
    // Avoid destroying render targets unnecessarily.  Only do it if our dimensions have actually changed.
    if (m_imageWidth != width || m_imageHeight != height)
    {
        m_imageWidth = width;
        m_imageHeight = height;

        // Destroy the current render targets and let them get recreated on our next draw
        DestroyRenderTargets();
    }

    glBindFramebuffer(GL_FRAMEBUFFER, getMainFBO());

    glViewport(0, 0, m_imageWidth, m_imageHeight);
}
Пример #3
0
/**
 * Shutdown the render manager
 */
bool RenderManager::Destroy()
{
	if(unitSphereMesh)	delete unitSphereMesh;
	if(unitConeMesh)	delete unitConeMesh;
	if(fullScreenVB)	gRenderAPI->DestroyVertexBuffer(fullScreenVB);
	if(fullScreenIB)	gRenderAPI->DestroyIndexBuffer(fullScreenIB);
	if(defaultTexture)	gRenderAPI->DestroyTexture(defaultTexture);

	cachedSamplers.clear();

	DestroyFonts();
	DestroyShaders();
	DestroyRenderTargets();
	gRenderAPI->Destroy();

	return true;
}