glut game-mode window/fullscreen switching?

hi,
we are making a game, which uses glut for window creation. i followed a tutorials on glut gamemode over at http://www.lighthouse3d.com/opengl/glut/index.php3?gameglut and from what it looks like (the VC example on that page) you first need to create a window, no matter what, and then if u want to go to fullscreen, enable game mode. and if u want to go back to windowed mode from fullscreen, u just leave game mode. that’s exactly what the example does. however, there is one small difference: in the example in never goes to fullscreen right away, instead it only does that when you press an appropriate button (F1, for example). that means that it completes at least one main loop. but it our project, if you last quit while you were in fullscreen mode, it should automatically go to fullscreen mode when you start it up again (screen mode is saved in a file, and read at prog start up), therefore not yet completing a main loop even once. i don’t know if that makes a difference, but i want to note each small detail. the problem is, that everytime i do that, it gives a fatal error (referenced to wrong part of memory), and if i try to debug, it ends up in assembly code (i think that the code is from glut32.dll).

has anyone ever used glut with resolution change support? if yes, have you incountered a similar problem? if so, could you please give me a pointer at where to look at? because from what it looks like, beside the above mentioned difference, our code (my project (note: it’s 2d), and the glut example - which works) has no other (noted by me) differences. and i want to do something like that… (unless you have a better solution)

any help is greately appreciated!

p.s. i need help specifically with glut gamemode, especially with entering and leaving it.

Use GLFW instead

With GLFW you go to fullscreen mode instantly, when open the window, like this:

glfwOpenWindow( 800,600, 8,8,8,0, 0,0, GLFW_FULLSCREEN );

(which opens a 24-bit color mode fullscreen window @ 800 x 600, no depth buffer, no stencil buffer)

You leave fullscreen mode when you close the window

glfwCloseWindow();

It’s as simple as that.

hmm…

i’ll take a look at this GLFW of yours… never heard of it before though. :-\ can anyone help me understand why the example works and my proj doesn’t? should i post my code here?

that glfw looks interesting (tried it out).

i was wondering if it’s possible to switch resolutions after creating a fullscreen window. it does’t mention that in the manual.

or would i have to close that window, and make another one? but then i have to reload all my OpenGL textures, don’t i? or do i have to do that (reload textures, reinit ogl, etc.) either way, even if i don’t close the window?

thanks for your help.

Post the glut code and I will have a look for you! But as Marcus says, glut does not do “gamemode” very well. Was bolted on late rather than being “designed in” from the beginning …

But, in the interests of GLUT, , I’ll check and see if there’s anything odd you have done. It’s often easier for someone else to spot a “silly”, after staring at code for ages …

Rob.

[This message has been edited by Rob Fletcher (edited 05-16-2002).]

oh well, i switched to glfw (of course kept the old glut copy), gonna see how that works out.

oh man, you have no idea how long it takes to convert everthing from glut to glfw… hundreds (if not thousands) of lines in each of 15 cpp files… :-\

I’m not into shoving my own code down
people’s throats. So I’ll just mention
there is another alternative in
Cpw .

In this library changing video modes is
handled independantly from window creation,
so that you can change modes based on
user selection. You can also query the
system for a list of available modes.
The library is modeled after glut, but is
not compatible with it. If your having
trouble switching over to a brand new API,
you might take a look at Cpw. GLUT -> Cpw
conversions are fairly easy to do. I’ve ported a
number of basic GLUT samples over in short
order.

Regards,
Jim

[This message has been edited by jmathies (edited 05-17-2002).]

On your specific problem, sounds like
at least one trip through glutMainLoop
is required. (You could download and compile
the debug version of the glut source so you
could debug the problem for sure.) Since
you can’t jump into glutMainLoop “just once”
check out the hacks available which add a
re-entrant main loop to the library. Both are referenced
in these discussion groups.

Regards,
Jim

[This message has been edited by jmathies (edited 05-17-2002).]

For reference:

Rob Fletcher’s glutCheckLoop: http://www-users.york.ac.uk/~rpf1/glut.html

Steve Baker’s glutMainLoopUpdate: http://www.sjbaker.org/steve/software/glut_hack.html