Jump to content
  • Advertisement
Sign in to follow this  
malborojones

DirectX 9 switching window state

This topic is 2607 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

Hellow :)
I've searched for about 2 hours around the web for a guide on how to switch a window from windowed to full screen after runtime.
I can do it fine at run time but I want to be able to switch back and forth.

I've made this method but when it's called the screen just goes white:

First it creates the new window style and updates the window




//Create new window style
DWORD style = (windowed) ?
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX :
WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE;

//set new window style
SetWindowLong(mHwnd, GWL_STYLE, style);
ShowWindow(mHwnd, SW_SHOW);
UpdateWindow(mHwnd);




then updates the present parameters for the device



mPresent.hDeviceWindow = mHwnd;
mPresent.Windowed = (windowed) ? TRUE : FALSE;
mPresent.BackBufferFormat = (windowed) ? D3DFMT_UNKNOWN : D3DFMT_X8R8G8B8;



mPresent are the present parameters used initially to create the device so I just update the values that need to be changed.

Next I call reset with the new parameters



hr = mDevice->Reset(&mPresent);

if (FAILED(hr))
{
if(hr == D3DERR_DEVICELOST)
ErrMsg("Device Lost");

if(hr == D3DERR_DEVICEREMOVED)
ErrMsg("Device Removed");

if(hr == D3DERR_DRIVERINTERNALERROR)
ErrMsg("Driver Error");

if(hr == D3DERR_OUTOFVIDEOMEMORY)
ErrMsg("Out of memory");
}



After this is done I don't get any of the errors that the MS site says it returns so none of the messages are shown but if I check if hr has failed I do get an error and hr has the value -2005530516

So what am I doing wrong? I keep seeing something about "state blocks" being released before calling Reset but I have no idea what they are and presume I haven't used any that need to be released.

So, any idea how to go about this correctly?

Thanks, Mal.
ph34r.gif

Share this post


Link to post
Share on other sites
Advertisement

[quote name='ryan20fun' timestamp='1306250986' post='4815150']
Try Reading This


What's this? xD
[/quote]

link pointed to my local one :P

Share this post


Link to post
Share on other sites
I understand the whole windows style stuff (that's what the link you gave me seems to be on)
when I try switching, the style of the window changes as it should e.g. the borders disappear when it should be full screen and show again when it's set to windowed but the window just goes white. That doesn't really make much sense because my render function clears the screen black before anything else.

Also before changing I have two sprites on the screen that I can move around with the arrow keys, once I try to switch mode they disappear as well as the screen going white.

Share this post


Link to post
Share on other sites
the DirectX device could be lost, i hade that when i was experimenting with Fullscreen and then minimizeing it.
you need to resoet the device and reload your assets (refer to the DirectX documentation on what needs to be reloaded, but as far as i know you have to reser and reload everything but shaders)

Share this post


Link to post
Share on other sites
what you can do is create a borderless window at the current screen resolution to fake full screen.
what you could do is to reset the device with nre presentation params that state that it should be fullscreen.

Share this post


Link to post
Share on other sites
May I direct you to the very well written tutorial/article of Evil Steve about this particular subject here? Hope this helps.

Share this post


Link to post
Share on other sites
So do you mean that all textures have to be reloaded, sprites remade etc.?[/quote]
Not if they're created with D3DPOOL_MANAGED...

You only have to release and recreate unmanaged resources when you do a device reset. In most cases, the only reason you would ever create an unmanaged resource is if it can't be managed (e.g. D3DUSAGE_DYNAMIC).

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!