[DX10] Viewport size?

Started by
2 comments, last by Demirug 15 years, 9 months ago
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
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.
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
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.

This topic is closed to new replies.

Advertisement