Jump to content
  • Advertisement
Sign in to follow this  
ArthY303

[SOLVED]Switching between windowed and fullscreen

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

Hello all ... I have a little problem and I don't know how to solve it.I'm working in DirectX and I have a problem whenever switching from windowed to fullscreen and viceversa. So the steps I follow when changing the window state are : - change the style of the window by the SetWindowLong() function - call SetWindowPos function in order for the change to become visible - change the D3DPresent_Parameters structure accordingly - reset the graphics device with the Reset() function. The program seems to be working I mean it changes the style of the window when I switch to fullscreen but it doesn't take up all the screen , the window has the same size with a changed style.Also when changing from fullscreen to windowed kinda the same thing happens only that the window seems to take up all the screen but now has a border , a title etc... I don't know what I'm doing wrong.I'm looking forward to your replies. [Edited by - ArthY303 on August 17, 2008 3:47:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
OK... so here is how I do it :

dwstyle is the style of the window :

- when the window state is windowed : dwstyle = WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX;
- when the window is in full screen mode : dwstyle = WS_EX_TOPMOST | WS_POPUP | WS_VISIBLE;

I use a function to set the state of the window , which changes the style too.

if(dwstyle != GetWindowLongPtr(windowHandle , GWL_style))
SetWindowLongPtr(windowHandle , GWL_style , dstyle);

SetWindowPos(windowHandle , NULL , posX , posY , Width , Height , SWP_FRAMECHANGED | SWP_SHOWWINDOW);

This is how I change the style of the window.

After that I change my D3DPRESENT_PARAMETERS structure by :

D3Dpp.Windowed = windowState (the current window state)

after that I reset the graphics device :

graphicsDevice->Reset(&D3Dpp);

That's it.

Share this post


Link to post
Share on other sites
By resetting the window size I mean changing the width and height.
What are the values of width and height when you change to fullscreen?

EDIT: And the posX and posY too :D

Share this post


Link to post
Share on other sites
Sorry the repost but I just noticed two things...
I don't know if this is a typing error or if you did a copy&paste, so... You're putting the GetWindowLongPtr value in dwstyle but you're using the dstyle in the SetWindowLongPtr function instead.
Anyway, did you check the dwstyle value after the GetWindowLongPtr call? Just to know if it's right ;)

Sorry if I'm not helping much but I'm a beginner... :|

Share this post


Link to post
Share on other sites
Is your program draw anything to the screen? If not your dx device maybe lost. Check reset function's return value. Normally if you want real fullscreen you don't need to change wındow style when switching windowed-fullscreen mode. When using reset function you beware some situations. If your rescues creted with POOL_DEFAULT parameter rescues will place in video memory. At this point when resetting device you need to release rescues before reset and recreate them after reset. If your rescues creted with POOL_SYSTEMMEM or POOL_MANAGED you don't need to release/recreate rescues. You can xcall reset function directly wehen device is lost. Take a look this article Responding to a Lost Device

Share this post


Link to post
Share on other sites
Well I set the width to 1024 and the height to 768 which are the width and height of the back buffer also. posX is set to 0 and likewise posY.

I'm just checking dwstyle to see if it is different than the current style .. as a result if the window state is windowed and you call the function again with the windowed parameter not to change it again but to ignore it.

Share this post


Link to post
Share on other sites
3ddreams what does "rescues" mean ? ... and I am checking for lost devices with
the TestCooperativeLevel() function ...

Share this post


Link to post
Share on other sites
textures, vertex buffers ...

If you load textures with D3DXCreateTextureFromFile function textures will locate in video memory by default. By the D3DXCreateTextureFromFileEx you can locate texturs to other locations.(system mem, managed). Create(Vertex/Index)Buffer function have parameter for choosing location. As I said if your rescues locate in video memory you must release them before reset then reload.

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!