Advertisement

windowed/fullscreen modes switching in glut?

Started by May 13, 2002 10:44 AM
1 comment, last by shurcool 22 years, 9 months ago
hi, we are making a game, which uses glut for window creation. i followed the tutorials on glut 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''m assuming 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. any help is greately appreciated! --- umm... bah?
I use glut, and switch window/fullscreen all the time.

I have a config and preference file that can startup in either mode. I don''t use the gamemode, I just setup my initial window, then conditionally enter fullscreen. (I don''t see the initial "window"):

log_message("Initing glut...");
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(400,400);
glutInitWindowPosition(0,0);
screen.windowID=glutCreateWindow(title);
if (pref.fullscreen) {
glutFullScreen();
glutSetCursor(GLUT_CURSOR_NONE);
}
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutSpecialFunc(specialdown);
glutSpecialUpFunc(specialup);
glutMotionFunc(motion);
glutPassiveMotionFunc(motion);
glutMouseFunc(mouseCB);

init(); // framework init

glutTimerFunc(10, timer, hw->timern); // prep for display in 10.9.8...
log_message("Ready.\n");
glutMainLoop();
}
-------------------------------------------------------

After that a ''f'' keypress toggles fullscreen/window back and forth:
if (fullscreen) {
glutFullScreen();
glutSetCursor(GLUT_CURSOR_NONE);
} else {
glutReshapeWindow(pref.windowWidth,pref.windowHeight);
glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
}


I don''t change resolution, I always use the desktop settings (I despise monitor-switching)

zin
zintel.com - 3d graphics & more or less
Advertisement
i specifically need help with game mode and switching resolutions, and back to windows desktop windowed mode. the commands for that would be glutEnterGameMode("640x480:32"); and glutLeaveGameMode(); (i think that's their names).

can anyone else help? thanks a lot.

---
umm... bah?

[edited by - shurcool on May 13, 2002 7:09:27 PM]

This topic is closed to new replies.

Advertisement