Advertisement

D3D9: Resize in Windowed Application

Started by May 28, 2011 07:21 PM
6 comments, last by malborojones 13 years, 6 months ago
Hello,

I have a D3D9 windowed application. When I create the device I do not specify any dimensions for the backbuffer. For example:

mPresentParams.BackBufferWidth = 0;
mPresentParams.BackBufferHeight = 0;

Now I wonder if I have to do anything when I resize the window? Do I have to reset() the device if the window is resized?
Creating your device that way means that it will create a back buffer with the same size as your window's client area. If the window changes size, you don't *have* to change your backbuffer size but if you don't, what you're rendering will appear either squashed or stretched. So if you don't want that to happen, you should reset the device so that the backbuffer continues to match the window size.
Advertisement
Hm ok. So after the window has been resized I just reset() the device with a new PresentParameters struct were BackBufferWidth and BackBufferHeight is again 0?

Hm ok. So after the window has been resized I just reset() the device with a new PresentParameters struct were BackBufferWidth and BackBufferHeight is again 0?


Yes. Just don't forget that you cannot simply reuse the PresentParams structure you used to create the device, because it autimatically overwrites your 0 dimensions with the actual size. You have to set them back to zero.
Also, "just reset()" of course have to mean to do all what a device reset requires (freeing non-managed resources etc.).
Thanks for the hint with the resetting of width/height! I definitely would have missed that:)
Just don't make the same mistake I did and use D3DPOOL_DEFAULT for everything ;D Otherwise you'll have to release and recreate everything created using DEFAULT when you call device reset. USE MANAGED! tongue.gif
The only thing I have to do is call my font's OnResetDevice before and OnLostDevice after resetting the device.

Good luck, Mal ^_^
Never refuse a cup of tea, that's how wars are started.
Advertisement
The only thing I have to do is call my font's OnResetDevice before and OnLostDevice after resetting the device.


And Effect's and Sprite's ;)

[quote name='malborojones' timestamp='1306688931' post='4817163']The only thing I have to do is call my font's OnResetDevice before and OnLostDevice after resetting the device.


And Effect's and Sprite's ;)
[/quote]

If you're using them x) Sprite's are okay I think as long as you use the managed pool for their textures. I don't have to reload any of the sprites when calling Reset ^_^
Never refuse a cup of tea, that's how wars are started.

This topic is closed to new replies.

Advertisement