Searched for a while thinking this would have some obvious tutorials but I can't find anything... which makes me think I must be using the wrong wording because it seems obvious.

Anyway, when I create my project, I have have a constant resolution of 800x600 set. This is used to set up:

my window buffer description swap chain description depth stencil description viewport

So, if I want to change my resolution to 1920x1080 what do I need to do?

Do I need to re-describe all of these things each time I change resolution and re-create them? Do I need to do it for just some of them? (I know resizing the window itself isn't a big deal)

Either way it seems like a lot of things use your window size so I was hoping there would be something that updates them all or a function for each that's used when you are changing resolution and nothing else.


This is documented at: DirectX Graphics Infrastructure (DXGI): Best Practices and further discussed at DXGI Overview: Care and Feeding of the Swap Chain.

There are 3 basic calls involved, as follows:

This is used to switch between fullscreen and windowed modes; if you're not switching (i.e you're going from a fullscreen to a fullscreen mode, or from a windowed to a windowed mode) you don't need it.

In a fullscreen mode this changes the display resolution; in a windowed mode this changes the size of the window. However it doesn't resize any of the underlying D3D objects (such as your backbuffer, your depth/stencil buffer, etc), so for that you need:

This will resize the backbuffer to match either an application-provided size or the size of the client rect of your window, depending on parameters you specify. It will not resize your depth/stencil buffer.

To resize your depth/stencil buffer you should destroy it and recreate it. You already have the code needed to destroy it in your program's shut down code, and you already have to code needed to recreate it in your program's startup code, so it's highly recommended that you reuse those.

You will also need to reset your viewport manually, as well as manually recreate any render targets you're using which need to match the window size/video mode.

It's also highly recommended that you read the first two links I've provided very carefully, as well as the individual documentation for each call. There are some corner-cases where things may not work as you expect (it's best to ask separate questions about them if you run into them) and DXGI will operate in one of two modes: either it will handle most things automatically for you (but it may not do so the way you want) or you will have to do all the work yourself, depending on if you've used IDXGIFactory::MakeWindowAssociation or not.

My recommendation is to not put this code into your own program just yet. Instead make a standalone program that just draws a black screen, and work through mode changing in that until you have a good understanding of what needs to be done and when and how to do it.

DXGI has it's own logic and if you use it the way it was designed to be used you'll do fine; if you try to fight against it or try to shoe-horn a different way of working onto it, you'll create a mess. It's best to have that learning experience in a separate program.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.