The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Full Screen To Windowed-Other Windows Lose Position???
JeZ-l-Lee


Joined: 20 Sep 2009
Posts: 572
Location: Long Island, New York, United States, Earth
Full Screen To Windowed-Other Windows Lose Position???

Hi,

My game supports both windowed and full screen.

I noticed that if I go from full screen to windowed,
the other open windows lose their original positions on the screen?

Any way to fix this?
( SDL 1.2 + OpenGL(R) on Windows 7)

Thanks!
Full Screen To Windowed-Other Windows Lose Position???
John Magnotti
Guest

Quote:
I noticed that if I go from full screen to windowed,
the other open windows lose their original positions on the screen?
when you go to full screen are you changing the original resolution?


John
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Torsten Giebl


Joined: 12 Sep 2009
Posts: 172
Hello !


Quote:
Full Screen To Windowed-Other Windows Lose Position???

Hi,

My game supports both windowed and full screen.

I noticed that if I go from full screen to windowed,
the other open windows lose their original positions on the screen?

This happened since the first days of SDL supporting OpenGL,
but it is only a problem on Windows, Linux and OSX are fine.

Other OpenGL games not using SDL, have the same problem.

It does not matter if you use an ATI or NVIDIA card.
I believe it is a thing from Microsoft to strike against OpenGL and
there is not much you can do about it.


CU
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Mason Wheeler
Guest

This is caused by doing full-screen the wrong way. When you switch to full screen mode, it actually changes your screen resolution for the entire system, which is a bad idea for several reasons, one of which being the effect you're seeing here. It's an example of what Raymond Chen calls "using global state to solve a local problem."


There's a right way to do full-screen, but it involves features that SDL doesn't officially support, and SDL 1.2 doesn't even unofficially support. Here's how it's done, though:


Set your SDL window size to the size of the current screen resolution (you'll have to query for that) before you go to full-screen mode. This way you don't cause a resolution switch.
Create a render target the size of the logical resolution you want to render to.
Do all your rendering to the render target, not the screen.
Once all rendering is finished, copy the render target to the screen and let OpenGL resize it to fit. (You may wish to correct for different aspect ratios.)



From: JeZ-l-Lee
To:
Sent: Wednesday, November 30, 2011 5:27 PM
Subject: [SDL] Full Screen To Windowed-Other Windows Lose Position???

Full Screen To Windowed-Other Windows Lose Position???

Hi,

My game supports both windowed and full screen.

I noticed that if I go from full screen to windowed,
the other open windows lose their original positions on the screen?

Any way to fix this?
( SDL 1.2 + OpenGL(R) on Windows 7)

Thanks!



JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft(R)
Video Game Design Studio
www.16BitSoft.com



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Torsten Giebl


Joined: 12 Sep 2009
Posts: 172
Hello !


Quote:
This is caused by doing full-screen the wrong way. When you switch to full screen mode, it actually changes your screen resolution for the entire system, which is a bad idea for several reasons, one of which being the effect you're seeing here. It's an example of what Raymond Chen calls "using global state to solve a local problem."

There's a right way to do full-screen, but it involves features that SDL doesn't officially support, and SDL 1.2 doesn't even unofficially support. Here's how it's done, though:

Set your SDL window size to the size of the current screen resolution (you'll have to query for that) before you go to full-screen mode. This way you don't cause a resolution switch.
Create a render target the size of the logical resolution you want to render to.
Do all your rendering to the render target, not the screen.
Once all rendering is finished, copy the render target to the screen and let OpenGL resize it to fit. (You may wish to correct for different aspect ratios.)

It works in DirectX without problems, even when switching resolutions.

Maybe someone has analyzed what functions DirectX calls to save the positions of all
the windows on the screen, but no OpenGL game on Windows, that i tested, ever restored the
Window positions correctly.

Other OS that use OpenGL for 3D do not have that problem,
Linux is fine, OSX is fine. Micrsoft tried always hard to
sabotage OpenGL in one way or another. Before releasing
Vista, MS said it would not support OpenGL anymore, hell
was breaking loose and then they changed their mind.

Today it is maybe less important, but in the older days
you simply had to change the resolution in a lot of cases.


CU
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Stephen Anthony
Guest

On December 1 2011, Torsten Giebl wrote:
Quote:
Hello !

Quote:
This is caused by doing full-screen the wrong way. When you switch
to full screen mode, it actually changes your screen resolution for
the entire system, which is a bad idea for several reasons, one of
which being the effect you're seeing here. It's an example of what
Raymond Chen calls "using global state to solve a local problem."

There's a right way to do full-screen, but it involves features that
SDL doesn't officially support, and SDL 1.2 doesn't even unofficially
support. Here's how it's done, though:

Set your SDL window size to the size of the current screen resolution
(you'll have to query for that) before you go to full-screen mode.
This way you don't cause a resolution switch. Create a render target
the size of the logical resolution you want to render to. Do all your
rendering to the render target, not the screen.
Once all rendering is finished, copy the render target to the screen
and let OpenGL resize it to fit. (You may wish to correct for
different aspect ratios.)

It works in DirectX without problems, even when switching resolutions.

Maybe someone has analyzed what functions DirectX calls to save the
positions of all the windows on the screen, but no OpenGL game on
Windows, that i tested, ever restored the Window positions correctly.

Other OS that use OpenGL for 3D do not have that problem,
Linux is fine, OSX is fine. Micrsoft tried always hard to
sabotage OpenGL in one way or another. Before releasing
Vista, MS said it would not support OpenGL anymore, hell
was breaking loose and then they changed their mind.

Today it is maybe less important, but in the older days
you simply had to change the resolution in a lot of cases.

I've researched this is some detail for Stella, the Atari 2600 emulator I
work on. In fact, I got so many questions about it that I added an FAQ
entry for it.

It seems to be related to the version of DirectX that SDL uses. I think
the issue was solved in DirectX 7,but SDL 1.2 still uses DirectX 5. I
initially contemplated porting SDL 1.2 to DirectX 7 to fix this, but I
don't have the time. I'd hoped it would be fixed in SDL 1.3. If it isn't,
perhaps I'll look into it again.

Steve A.
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Stephen Anthony
Guest

On December 1 2011, Mason Wheeler wrote:
Quote:
This is caused by doing full-screen the wrong way. When you switch to
full screen mode, it actually changes your screen resolution for the
entire system, which is a bad idea for several reasons, one of which
being the effect you're seeing here. It's an example of what Raymond
Chen calls "using global state to solve a local problem."

There's a right way to do full-screen, but it involves features that
SDL doesn't officially support, and SDL 1.2 doesn't even unofficially
support. Here's how it's done, though:

Set your SDL window size to the size of the current screen resolution
(you'll have to query for that) before you go to full-screen mode.
This way you don't cause a resolution switch. Create a render target
the size of the logical resolution you want to render to. Do all your
rendering to the render target, not the screen.
Once all rendering is finished, copy the render target to the screen
and let OpenGL resize it to fit. (You may wish to correct for
different aspect ratios.)

I don't think that fixes the problem entirely, though. For example, you
may wish to go to 640x480 fullscreen on a 1024x768 desktop. Even if you
do switch to 1024x786 window first, a mode-switch still has to occur when
going to 640x480, and returning from that mode will have the icons placed
in a 640x480 'rectangle'. That doesn't happen in other DirectX 7+
applications.

Steve
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Mason Wheeler
Guest

No, there's no mode switch. That's why you use a render target. The render target is
640x480, and you copy that onto your screen, which is still at 1024x768, and let the
hardware scale it up.



From: Stephen Anthony
Subject: Re: [SDL] Full Screen To Windowed-Other Windows Lose Position???

On December 1 2011, Mason Wheeler wrote:
Quote:
This is caused by doing full-screen the wrong way. When you switch to
full screen mode, it actually changes your screen resolution for the
entire system, which is a bad idea for several reasons, one of which
being the effect you're seeing here. It's an example of what Raymond
Chen calls "using global state to solve a local problem."

There's a right way to do full-screen, but it involves features that
SDL doesn't officially support, and SDL 1.2 doesn't even unofficially
support. Here's how it's done, though:

Set your SDL window size to the size of the current screen resolution
(you'll have to query for that) before you go to full-screen mode.
This way you don't cause a resolution switch. Create a render target
the size of the logical resolution you want to render to. Do all your
rendering to the render target, not the screen.
Once all rendering is finished, copy the render target to the screen
and let OpenGL resize it to fit. (You may wish to correct for
different aspect ratios.)

I don't think that fixes the problem entirely, though. For example, you
may wish to go to 640x480 fullscreen on a 1024x768 desktop. Even if you
do switch to 1024x786 window first, a mode-switch still has to occur when
going to 640x480, and returning from that mode will have the icons placed
in a 640x480 'rectangle'. That doesn't happen in other DirectX 7+
applications.

Steve
Full Screen To Windowed-Other Windows Lose Position???
David Olofson
Guest

On Thursday 01 December 2011, at 15.13.08, Mason Wheeler
wrote:
[...]
Quote:
There's a right way to do full-screen, but it involves features that SDL
doesn't officially support, and SDL 1.2 doesn't even unofficially
support. Here's how it's done, though:
[...desktop resolution + render target + hardware scaling...]

...or, just use the desktop resolution as the default resolution setting for
fullscreen mode, and adjust your matrices accordingly.

Compared to scaling the whole picture, it shouldn't really make much of a
difference performance wise, but might look better, depending on what you're
rendering. Unless you actually change the video mode, the scaling and
bandwidth impact of the (potentially very) high resolution will strike
*somewhere* anyway.

Well, UNLESS you have a lot of overdraw in the scene, that is! Particle
systems with large particles are particularly dangerous on large/high-res
screens, as the overdraw overhead quickly becomes massive.


--
//David Olofson - Consultant, Developer, Artist, Open Source Advocate

.--- Games, examples, libraries, scripting, sound, music, graphics ---.
| http://consulting.olofson.net http://olofsonarcade.com |
'---------------------------------------------------------------------'
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Full Screen To Windowed-Other Windows Lose Position???
Patrick Baggett
Guest

On Wed, Nov 30, 2011 at 7:27 PM, JeZ-l-Lee wrote:
Quote:
Full Screen To Windowed-Other Windows Lose Position???

Hi,

My game supports both windowed and full screen.

I noticed that if I go from full screen to windowed,
the other open windows lose their original positions on the screen?

Any way to fix this?
( SDL 1.2 + OpenGL(R) on Windows 7)





I don't really understand why this is so surprising. Let's say you worked at Microsoft and on the Windows code base. Someone calls your API to change the screen resolution from 1024x768 to 640x480. What do you do? Leave the windows off screen or move them? You move them. Let's say they call the function again a few minutes later and change it from 640x480 to 1024x768. How do you, the OS vendor know that "he's just putting the resolution back where it was?" How were you supposed to know that the first change from 1024x768 to 640x480 was "just temporary"? The same API is used by the control panel plugins to modify your screen size.


Hearing stuff like "Microsoft hates OpenGL and just wants to kill it etc etc" is just tinfoil hattery. If they wanted to kill OpenGL, they would simply do it. But then a ton of vendors for CAD programs and a few game writers would be forced to use Linux or Mac OS. Do you think MS wants thousands of shops using these programs to drop Windows as their main platform? The effects of dropping OpenGL would be monumentally bad from a technical standpoint, and horrible from a PR standpoint.


Something productive to test that might solve the problem is ChangeDisplaySettings() function, and how (if?) it is used in SDL. The second parameter is the flags, with one of note:


CDS_FULLSCREEN
The mode is temporary in nature.
If you change to and from another desktop, this mode will not be reset.
 
This might be used to tell the OS "this is temporary, remember where I put stuff". Anyone want to test the API in isolation? 






Quote:
Thanks!



JeZ+Lee
JessePalser <AT> Gmail <DOT> com
16BitSoft(R)
Video Game Design Studio
www.16BitSoft.com


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Full Screen To Windowed-Other Windows Lose Position???
Stephen Anthony
Guest

On 11-12-01 12:03 PM, Mason Wheeler wrote:
Quote:
No, there's no mode switch. That's why you use a render target. The render target is
640x480, and you copy that onto your screen, which is still at 1024x768, and let the
hardware scale it up.



Right, I meant in software mode, where you actually have to do the mode-switch and can't scale the image. In fact, your suggestion is exactly what I suggest in the Stella FAQ *when using OpenGL*. When using software mode, you'll be stuck with the re-arrangement of icons/windows unless SDL uses DirectX 7+.

Steve
Full Screen To Windowed-Other Windows Lose Position???
Patrick Baggett
Guest

On Thu, Dec 1, 2011 at 10:47 AM, Stephen Anthony wrote:
Quote:
On 11-12-01 12:03 PM, Mason Wheeler wrote:
Quote:
No, there's no mode switch.  That's why you use a render target.  The render target is
640x480, and you copy that onto your screen, which is still at 1024x768, and let the
hardware scale it up.




Right, I meant in software mode, where you actually have to do the mode-switch and can't scale the image.  In fact, your suggestion is exactly what I suggest in the Stella FAQ *when using OpenGL*.  When using software mode, you'll be stuck with the re-arrangement of icons/windows unless SDL uses DirectX 7+.


DX7 for mode changing? 


 
Quote:
Steve



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Full Screen To Windowed-Other Windows Lose Position???
Stephen Anthony
Guest

On 11-12-01 1:39 PM, Patrick Baggett wrote:
Quote:


On Thu, Dec 1, 2011 at 10:47 AM, Stephen Anthony wrote:
Quote:
On 11-12-01 12:03 PM, Mason Wheeler wrote:
Quote:
No, there's no mode switch. That's why you use a render target. The render target is
640x480, and you copy that onto your screen, which is still at 1024x768, and let the
hardware scale it up.




Right, I meant in software mode, where you actually have to do the mode-switch and can't scale the image. In fact, your suggestion is exactly what I suggest in the Stella FAQ *when using OpenGL*. When using software mode, you'll be stuck with the re-arrangement of icons/windows unless SDL uses DirectX 7+.


DX7 for mode changing?



See my previous messages for the context of this statement. This info is what I gathered from various sources. In fact, if you search the archives of this mailing list, you'll see I've commented on this issue before.

Steve
Full Screen To Windowed-Other Windows Lose Position???
Patrick Baggett
Guest

On Thu, Dec 1, 2011 at 12:00 PM, Stephen Anthony wrote:
Quote:
On 11-12-01 1:39 PM, Patrick Baggett wrote:
Quote:


On Thu, Dec 1, 2011 at 10:47 AM, Stephen Anthony wrote:
Quote:
On 11-12-01 12:03 PM, Mason Wheeler wrote:
Quote:
No, there's no mode switch.  That's why you use a render target.  The render target is
640x480, and you copy that onto your screen, which is still at 1024x768, and let the
hardware scale it up.




Right, I meant in software mode, where you actually have to do the mode-switch and can't scale the image.  In fact, your suggestion is exactly what I suggest in the Stella FAQ *when using OpenGL*.  When using software mode, you'll be stuck with the re-arrangement of icons/windows unless SDL uses DirectX 7+.


DX7 for mode changing?




See my previous messages for the context of this statement.  This info is what I gathered from various sources.  In fact, if you search the archives of this mailing list, you'll see I've commented on this issue before.




I don't think using DX7 is a very good way to solve it when there are native APIs to do so that don't involving a) requiring DXSDK b) loading old DX DLLs (not future proof when they are already deprecated) and c) runtime creation of DX objects just to do mode changes. My 2c.


Patrick
Full Screen To Windowed-Other Windows Lose Position???
Stephen Anthony
Guest

On 11-12-01 1:37 PM, Patrick Baggett wrote:

Quote:
Hearing stuff like "Microsoft hates OpenGL and just wants to kill it etc etc" is just tinfoil hattery. If they wanted to kill OpenGL, they would simply do it. But then a ton of vendors for CAD programs and a few game writers would be forced to use Linux or Mac OS. Do you think MS wants thousands of shops using these programs to drop Windows as their main platform? The effects of dropping OpenGL would be monumentally bad from a technical standpoint, and horrible from a PR standpoint.

I agree that not *every* decision that MS makes in this area is to kill OpenGL. However, they do make things as hard as possible, and would *really* like if OpenGL just disappeared and everyone used DirectX. Of course they won't just kill it out-right. As you say, that would force people elsewhere. But the more insidious approach is to make it as undesirable as possible to use OpenGL, hoping that eventually everyone will see the light and start using DirectX entirely.

OpenGL support in Windows *is* a second-class citizen, and it would be foolish to assume it's completely because of technical reasons. OSX and Linux manage to handle OpenGL very well (in the case of Linux, when you have good drivers), so there's no reason that Windows couldn't either.

Quote:
Something productive to test that might solve the problem is ChangeDisplaySettings() function, and how (if?) it is used in SDL. The second parameter is the flags, with one of note:


CDS_FULLSCREEN
The mode is temporary in nature.
If you change to and from another desktop, this mode will not be reset.

This might be used to tell the OS "this is temporary, remember where I put stuff". Anyone want to test the API in isolation?



I agree, someone (maybe me!) should look into this and see what can be done about it.

Steve
Full Screen To Windowed-Other Windows Lose Position???
Torsten Giebl


Joined: 12 Sep 2009
Posts: 172
Hello !


Quote:
I don't really understand why this is so surprising. Let's say you worked
at Microsoft and on the Windows code base. Someone calls your API to change
the screen resolution from 1024x768 to 640x480. What do you do? Leave the
windows off screen or move them? You move them. Let's say they call the
function again a few minutes later and change it from 640x480 to 1024x768.
How do you, the OS vendor know that "he's just putting the resolution back
where it was?" How were you supposed to know that the first change from
1024x768 to 640x480 was "just temporary"? The same API is used by the
control panel plugins to modify your screen size.

You are right, this is true. I wonder what DirectX does to prevent this.

Quote:
Hearing stuff like "Microsoft hates OpenGL and just wants to kill it etc
etc" is just tinfoil hattery. If they wanted to kill OpenGL, they would
simply do it. But then a ton of vendors for CAD programs and a few game
writers would be forced to use Linux or Mac OS. Do you think MS wants
thousands of shops using these programs to drop Windows as their main
platform? The effects of dropping OpenGL would be monumentally bad from a
technical standpoint, and horrible from a PR standpoint.

When Vista came out, they tried to kill OpenGL, only Software OpenGL, no
HW OpenGL anymore. After hell was breaking loose, they stepped back,
saying that vendors like NVIDIA and ATI could still support HW OpenGL with
their drivers.

Quote:
Something productive to test that might solve the problem is
ChangeDisplaySettings()
function, and how (if?) it is used in SDL. The second parameter is the
flags, with one of note:

*CDS_FULLSCREEN*

The mode is temporary in nature.

If you change to and from another desktop, this mode will not be reset.

I am currently not on a Windows Machine, it would be great if
someone could test this out. If that is true, basically every major OpenGL game
is doing it wrong.


CU
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
Norfanin


Joined: 21 Jan 2012
Posts: 25
I found this thread on gamedev. Using the CDS_FULLSCREEN flag for the change from the smaller to the original resolution indeed keeps the windows in their original place.

Is this known? Could this have any side effects?

Code:
diff -r 39e9d0e94190 src/video/windib/SDL_dibvideo.c
--- a/src/video/windib/SDL_dibvideo.c   Fri Jan 20 22:58:01 2012 -0500
+++ b/src/video/windib/SDL_dibvideo.c   Sat Jan 21 16:03:16 2012 +0100
@@ -807,7 +807,7 @@
    } else {
 #ifndef NO_CHANGEDISPLAYSETTINGS
       if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
-         ChangeDisplaySettings(NULL, 0);
+         ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
       }
 #endif
       if ( flags & SDL_NOFRAME ) {
@@ -1186,7 +1186,7 @@
          }
 #ifndef NO_CHANGEDISPLAYSETTINGS
          if ( this->screen->flags & SDL_FULLSCREEN ) {
-            ChangeDisplaySettings(NULL, 0);
+            ChangeDisplaySettings(NULL, CDS_FULLSCREEN);
             ShowWindow(SDL_Window, SW_HIDE);
          }
 #endif