Hello All,
I'm having a problem ( actually its been in my engine for over 9 months now and I want to lance it ). I'm trying to do a mode toggle from fullscreen to windowed and vice versa in OpenGL on Windows. Yes I know that the NeHe tutorials do a mode toggle but that destroys the entire application. I don't want to do that, if I can help it. Anyway the algorithm that I've implemented works when both the desktop and fullscreen colour bit depth is the same, however when the colour depths are different (desktop 16 bits, fullscreen 32 bits) I get the following error message:
Failed to set the pixelformat for the current device cColorBits: 32, cDepthBits: 24, cStencilBits: 0, Errorcode: 0x000007d0
the errorcode value is the value being returned from GetLastError() which I believe means "pixelformat is invalid". The algorithm that I'm using to do the mode toggle is as follows:
delete pixelformat (deletes rendering and device contexts)
toggle window state
set new displaymode
setup new pixelformat (create new device and render contexts)
any helps much appreciated,
netwalker.
OpenGL: Mode Toggling
Started by netwalker, Dec 12 2008 11:46 AM
7 replies to this topic
#1
Posted 12 December 2008 - 11:46 AM
#2
Posted 12 December 2008 - 12:52 PM
From the MSDN, in regards to SetPixelFormat:
So, the correct way to do this would be to destroy the entire window, and recreate it again.
By the way, why do you want to support different target window pixel formats ?
Also note, that for normal display mode changes (i.e. windowed to fullscreen) or resolution changes, you won't need to touch the pixel format of your window...
Cheers,
- Wern
Quote
If hdc references a window, calling the SetPixelFormat function also changes the pixel format of the window. Setting the pixel format of a window more than once can lead to significant complications for the Window Manager and for multithread applications, so it is not allowed. An application can only set the pixel format of a window one time. Once a window's pixel format is set, it cannot be changed.
So, the correct way to do this would be to destroy the entire window, and recreate it again.
By the way, why do you want to support different target window pixel formats ?
Also note, that for normal display mode changes (i.e. windowed to fullscreen) or resolution changes, you won't need to touch the pixel format of your window...
Cheers,
- Wern
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)
#3
Posted 12 December 2008 - 02:05 PM
Wernaeh said:
From the MSDN
Wernaeh said:
By the way, why do you want to support different target window pixel formats ?
Wernaeh said:
for normal display mode changes (i.e. windowed to fullscreen) or resolution changes, you won't need to touch the pixel format of your window...
thanks.
#4
Posted 12 December 2008 - 05:04 PM
Quote
Does that include changes to colour depth too?.
No, I don't think so - just consider that maybe a 16bit colour depth is only supported with a 16-bit depth buffer, so they can have interleaved colour / depth in a 32-bit-per-pixel format. Now if you change colour resolution from 32-bit to 16-bit, your old format may not be supported anymore.
I can even remember that some old hardware (GeForce 1 era) trashed all video memory resources on normal display changes as well, so you still had to reload textures and similar - the clean way always is to recreate the window, as far as I know (Anybody out there can make a definitive statement on that?)
Cheers,
- Wernaeh
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)
#5
Posted 12 December 2008 - 05:05 PM
netwalker said:
Does that include changes to colour depth too?.
Edit: Too slow, and probably wrong :)
"Stupid bug! You go squish now!!" - Homer Simpson
#6
Posted 12 December 2008 - 06:01 PM
netwalker said:
Unless of course I can make a "safe assumption" that everybody is now using 32bit desktops
Honestly, that sounds like a pretty safe assumption to me.
reedbeta.com - developer blog, OpenGL demos, and other projects
#7
Posted 13 December 2008 - 01:36 AM
Quote
Honestly, that sounds like a pretty safe assumption to me.
That's the way I'd suggest for almost all projects, as well - especially smaller, private ones.
Just settle with maybe one or two pixel formats your app supports - and tell the user to upgrade his hardware if these aren't available. These days, almost all hardware will support 32-bit Colours 24-bit Depth 8-bit Stencil - so why go for anything else ?
Cheers,
- Wernaeh
Some call me mathematician, some just call me computer guy. Yet, I prefer the term professional weirdo :)
#8
Posted 17 December 2008 - 01:12 PM
It makes things really simple by using one pixelformat. If of course my users start moaning about not supporting 16 bit color depths I can always redirect them here... hehehe.
Thanks a lot for input guys.
netwalker.
Thanks a lot for input guys.
netwalker.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












