• Advertisement
Sign in to follow this  

[DX10] Viewport size?

This topic is 3450 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I'm having trouble setting up the Viewport when resizing the window. Initially, I set the size of the SwapChain AND the Size of the Viewport to the ClientSize of the window. When changing the size of the window, I change the size of the SwapChain. When I change the size of the Viewport as well, the output not correct. If I leave the size of the Viewport to its original size, the output is rendered correctly to the resized window. What is the Viewport size for? I thought it must have the same size as the output window. What happens when I change the Viewport's size? I really don't understand the meaning of the Viewport size and how to set it when changing the size of the output window. Can somebody help me please? Christian

Share this post


Link to post
Share on other sites
Advertisement
To change the size of the back buffers in the swap chain you need to release any views that uses the back buffer texture and the back buffer texture. Then you can call ResizeBuffers and recreate your views. If you do this wrong you will still use the old back buffers with the old size. Direct3D will scale this to the new window size.

Share this post


Link to post
Share on other sites
When resizing the window, I dispose the old SwapChain and create a new one with the new width and height.

But which size do I have to set the viewport to? In DirectX9 I never used the viewport, I just set the shader matrices.

What does the viewport in general? For example, when rendering to an offscreen texture, do I have to set the viewport to the size of the texture?

Thanks,
Christian

Share this post


Link to post
Share on other sites
The viewport defines the area of your back buffer were everything will be rendered. As long as you don’t want to do split screen or similar effects the viewport should be the same size as your render target.
You don’t need to dispose you’re your swap chain. Just reset the buffer size and recreate the render target view.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement