Sign in to follow this  
ArthY303

[SOLVED]Switching between windowed and fullscreen

Recommended Posts

ArthY303    1153
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
ArthY303    1153
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
KosmiC_Khaoz    122
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
KosmiC_Khaoz    122
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
3ddreams    142
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
ArthY303    1153
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    142
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
Aardvajk    13207
Quote:
Original post by ArthY303
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...


Total guess, but is it possible you've got your values for the Windowed member of your present parameters back to front? I.e. true for fullscreen and false for windowed instead of the otherway round. That could cause the problems you are describing if your fullscreen mode is the same resolution as your desktop and you aren't clearing the backbuffer.

As an irrelevance, the size of your window is not significant when going into fullscreen mode - the mode is just set to the size of your backbuffer, assuming the card and monitor support it, regardless of the window size.

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