Need to do fullscreen, but it doesn't work.

Hi,

I am currently writing a driver for our 3D engine (which is currently Windows) and have split the whole framework into the following classes:

  1. base application - this handles the platform specific creation/destruction of windows.

  2. application - this is derived from base application and includes driver enumeration and calls the correct parts of the driver.

We then have the driver which can be swapped in and out of memory with other drivers.

I am working on the OpenGL driver and have a create function that is called after the window is created which gets all the screen resolutions and sets up the pixel format and all the other stuff needed. This works fine.

I also have a destruction which is called on destroy.

Now the problem I have is that I need to be able to go fullscreen or back to a window at will. I have tried to put calls to ChangeWindowSettingsEx() with CDS_FULLSCREEN (or 0) to do that, but it doesn’t work.

Is there a way of either doing this without having to destroy the window and then recreate it? Or can I safely use DirectDraw to do the fullscreen/window change?

When I include the code to do the mode change it puts me into a window (the 0 parameter) that is 800x600x16 - which is not correct, I actually want a window on the desktop.

But, then when I try to go fullscreen, it tries, then gives me a window with my scene in, but the scene is not animated anymore and the objects are white. It should also be fullscreen and it isn’t - although the window controls aren’t there anymore.

This is strange, any ideas as to how I can achieve this?

Thanks,
Luke A. Guest.

[QUOTE]Originally posted by Lucretia:

Is there a way of either doing this without having to destroy the window and then recreate it?
[QUOTE]
It is wiser to recreate window. BUT, you may also shange your window size (to smaller one) and change window style (borders …) - or schange to some other screen resulution.
You need to use some extra flags for this by creating your window at first time.

… your problem is quite blear to me, but i think you should look at NeHe page http://nehe.gamedev.net/opengl.asp
I hope it helps

Well, I have got it working, but it does close the window down and then recreates it.

I would still prefer not to do it this way. If there is a way of doing it whithout destroying the window can you advise me on this?

BTW, I have looked at the NeHe site and haven’t seen any code that does this…yet…I’ll have another look :wink:

Thanks,
Luke.

Lucretia, here’s my view on the subject, as i’m in a similar boat.

I strongly recommend that you close and recreate your window, but here’s as close as i could come w/ just one.

what you have to do is init your window style w/o the WS_OVERLAPPEDWINDOW flag. Just use WS_POPUP instead, and some other necessary ones, like WS_CLIPSIBLINGS && WS_CLIPCHILDREN. This will create a window w/out a border that is un-resizeable w/ the mouse. You don’t have to call CDS or set up a pixel format.

the obvious problems are just that, the user can’t change the window, no buttons, no resizing… moreover, when you go fullscreen, your limited to the pixelformat of the desktop, so there’s no way for the user to adjust the pixel format/resolution to maximize performance. in other words, it works, but it sucks…

(i’m sure you could overcome the resizing and buttons problems by drawing your own, using ogl, and mimicking win32 to the t, but why bother w/ win32 in the first place then? -lol )

okay, now, the reasons i recommend you kill and create the window every time are the exact opposite of why not to use the popup window. you can let win32 do it’s job! lol

the only trick is that you have to init ur gl and pixelformats each time, but that’s a breeze if u use a function each time to create the window, and it’s not just in winmain. just hook the glinitializations in w/ ur window inits, and you’re set.

-Succinct
“I have no name which you may call me. I am succinct, so call me such.”

p.s., besides i’m sure you know, the main reason you really can’t use a single window is because you can only set the pixelformat once, and that’s it.

p.p.s nehe’s tutorial #1 switches between fullscreen and windowed mode by pressing f1.
i think to tut’s point was to demo switching between fullscreen and windowed mode using ogl… .dunno, but it’s there, last time i checked

[This message has been edited by Succinct (edited 10-23-2000).]

Hi,
I thought just use changedisplaysettings(dmscreensetting,CDS_fullscreen) would do trick or am I wrong.

bye
Joachim

You an use ChangeDisplaySettings() but you have to kill the window before using it.

Luke.

Well is works fine without killing the window . I can swith to fullscreen an back.
No Problem.

It is always best to destroy the window since you do not know before hand, if the pixelformat will need to be changed by the process of switching display modes. Look at all major opengl apps that can be switched between windowed and fullscreen (except Unreal since in Windowed mode it runs in software), they all do in general the following:
[ul][li]Destroy the current rendering context[]Destroy the window[]Change display mode as needed[]Create a new window[]Create a new rendering context[]Get the extension pointers (since they can change between different contexts).[]And reload the textures[/ul][/li]This is a safe method of changing modes.

During our development I played with this a for a while. Here’s what I found: It worked well on Nvidia cards. But for example on a g400 it seemed to work, but I “lost” double buffering. It used 2 buffers but I could draw to only one.

My advice: Destroy your window.