How to resize render target?

Jan 6, 2015 at 3:39 PM
Edited Jan 6, 2015 at 3:40 PM
I want to change the render target to a different size (cx, cy) based on some configurable settings. But it does not work if I just change the size of the render target. What am I missing here? Currently, I'm doing something like:
Glyph3::RendererDX11::Get()->ResizeTexture(m_OffscreenTexture, cx, cy);
m_pPerspectiveView->Resize(cx, cy);
m_OffscreenTexture is the texture used as the render target. m_pPerspectiveView is a ViewPerspective object created as below:
m_pPerspectiveView = new Glyph3::ViewPerspective(*pRenderer, m_OffscreenTexture, m_DepthTarget);
Coordinator
Jan 9, 2015 at 1:58 AM
As a quick reference you can take a look at how the RenderApplciation resizes the back buffer and render targets when the Win32 window is resized:
void RenderApplication::HandleWindowResize( HWND handle, UINT width, UINT height )
{
    if ( width < 1 ) width = 1;
    if ( height < 1 ) height = 1;
    m_iWidth = width;
    m_iHeight = height;

    // Resize our rendering window state if the handle matches
    if ( ( m_pWindow != 0 ) && ( m_pWindow->GetHandle() == handle ) ) {
        m_pWindow->ResizeWindow( width, height );
        m_pRenderer11->ResizeSwapChain( m_pWindow->GetSwapChain(), width, height );
    }

    // Update the projection matrix of our camera
    if ( m_pCamera != 0 ) {
        m_pCamera->SetAspectRatio( static_cast<float>(m_iWidth) / static_cast<float>(m_iHeight) );
    }

    // Update the render views being used to render the scene
    if ( m_pRenderView != 0 ) {
        m_pRenderView->Resize( width, height );
    }

    // Update the text render view being used to render the scene
    if ( m_pTextOverlayView != 0 ) {
        m_pTextOverlayView->Resize( width, height );
    }
}
//--------------------------------------------------------------------------------
If you follow each method, you will see how to do the resizing. Basically it is calling resize on the resource with a renderer method, making sure your viewport is correct, and then making sure your aspect ratio is correct in the perspective matrix. Does this help at all?
Marked as answer by wxz on 1/9/2015 at 10:56 AM