Sign in to follow this  
schupf

D3D9: Resize in Windowed Application

Recommended Posts

Hello,

I have a D3D9 windowed application. When I create the device I do not specify any dimensions for the backbuffer. For example:
[code]
mPresentParams.BackBufferWidth = 0;
mPresentParams.BackBufferHeight = 0;
[/code]
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
[quote name='schupf' timestamp='1306618177' post='4816927']
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?
[/quote]

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.).

Share this post


Link to post
Share on other sites
Thanks for the hint with the resetting of width/height! I definitely would have missed that:)

Share this post


Link to post
Share on other sites
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! [img]http://public.gamedev.net/public/style_emoticons/default/tongue.gif[/img]
The only thing I have to do is call my font's OnResetDevice before and OnLostDevice after resetting the device.

Good luck, Mal ^_^

Share this post


Link to post
Share on other sites
[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.
[/quote]

And Effect's and Sprite's ;)

Share this post


Link to post
Share on other sites
[quote name='Tom KQT' timestamp='1306690571' post='4817174']
[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.
[/quote]

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 ^_^

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this