Skip to main content
GameDev.net gamedev.net
🔒 Locked

freeglut gamemode behaviour

Started by Clive McCarthy Sep 6, 2009 at 5:04 PM 1 replies 1.7k views
Original Post
Clive McCarthy
Clive McCarthy
There is not a great deal of solid documentation to be found about Glut's GameMode. I found the following on the web but I wonder if it is a reliable explanation of how GameMode _should_ function? Most examples merely show the application entering GameMode and never returning. I have an application that needs to go full-screen and also return to decorated window mode. I'm working with freeglut 2.4.0 on both Win XP and Linux Ubuntu and with a variety of graphics hardware: Nvidia 8800 to Intel 945GM. I get erratic behaviour -- sometimes the return from GameMode has the video driver very confused and a system has to be restarted -- on another platform the return takes several seconds. --quote: When game mode is entered, certain GLUT functionality is disable to facilitate high-performance fullscreen rendering. GLUT pop-up menus are not available while in game mode. Other created windows and subwindows are not displayed in GLUT game mode. Game mode will also hide all other applications running on the computer's display screen. The intent of these restrictions is to eliminate window clipping issues, permit screen display format changes, and permit fullscreen rendering optimization such as page flipping for fullscreen buffer swaps. The value returned by glutEnterGameMode is a unique small integer identifier for the fullscreen window. The range of allocated identifiers starts at one. This window identifier can be used when calling glutSetWindow. After leaving game mode, the GLUT functionality disabled in game mode is available again. The game mode window (and its OpenGL rendering state) is destroyed when leaving game mode. Any windows and subwindows created before entering the game mode are displayed in their previous locations. The OpenGL state of normal GLUT windows and subwindows is not disturbed by entering and/or leaving game mode. --unquote Here's a code fragment with my two functions the first to switch to full screen the second to return. I had a problem with just entering and leaving GameMode (freeglut says there is no window to resize after returning?) so I explicitly destroy the current window before entering GameMode and I explicitly create a new window after returning from GameMode. My application only has one window. The callbacks are re-registered after entering GameMode and whenever a new window is created. If I knew the design intent or even if there were a dependable definition, I could write explicitly for that and then start debugging the particular OS and hardware issues that may be present. Clive McCarthy /*------------------------------------------------------------------------------ ------------------------------------------------------------------------------*/ void switch_to_full_screen(void) { char mode_string[24]; full_screen = TRUE; sprintf(mode_string, "%dx%d:32@60", glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT)); glutGameModeString(mode_string); if(glutGameModeGet(GLUT_GAME_MODE_POSSIBLE)) { printf("GameMode %s is possible\n", mode_string); glutDestroyWindow(glut_pane_id); // destroys the current graphics window glutEnterGameMode(); glut_OpenGL_call_backs(); glutSetCursor(GLUT_CURSOR_NONE); // hide the cursor } else { printf("GameMode %s NOT possible\n", mode_string); glutFullScreen(); } #ifdef UBUNTU_PORT system("wmctrl -r\"FourteenthStreetStudio\" -b add,fullscreen,skip_taskbar"); #endif if(glutGameModeGet(GLUT_GAME_MODE_ACTIVE)) { printf("GameMode is now active...\n"); } else { printf("GameMode is NOT active\n"); } OpenGL_error_check(__FILE__, __LINE__); glutPostRedisplay(); } /*------------------------------------------------------------------------------ set the window's width and position for debugging Window managers (including gnome) adhere to a standard interface, the EWMH/NetWM specification. This allows programs that remote-control their functionality. And fortunately, someone already has written one called "wmctrl". ------------------------------------------------------------------------------*/ #ifdef __FREEGLUT__ #define WINDOW_X_ORIGIN 0 #define WINDOW_Y_ORIGIN 0 #else #define WINDOW_X_ORIGIN 4 #define WINDOW_Y_ORIGIN 24 #endif void set_debug_window_size(void) { int screen_width, screen_length; full_screen = FALSE; if(glutGameModeGet(GLUT_GAME_MODE_ACTIVE)) { printf("returning from GameMode\n"); glutLeaveGameMode(); glut_pane_id = glutCreateWindow("FourteenthStreetStudio"); glut_OpenGL_call_backs(); } #ifdef UBUNTU_PORT system("wmctrl -r\"FourteenthStreetStudio\" -b remove,fullscreen,skip_taskbar"); #endif screen_width = glutGet(GLUT_SCREEN_WIDTH); screen_length = glutGet(GLUT_SCREEN_HEIGHT); switch(screen_width) { case 3840: // dual screen WUXGA glutPositionWindow(WINDOW_X_ORIGIN + (screen_width / 2), WINDOW_Y_ORIGIN); glutReshapeWindow(1824, 1140); // 16:10 break; case 3200: // dual screen UXGA glutPositionWindow(WINDOW_X_ORIGIN + (screen_width / 2), WINDOW_Y_ORIGIN); glutReshapeWindow (1584, 990); // 16:10 break; etc. etc.
Sneftel
Sneftel
Quote:
Original post by Clive McCarthy
There is not a great deal of solid documentation to be found about Glut's
GameMode. I found the following on the web but I wonder if it is a reliable
explanation of how GameMode _should_ function? Most examples merely show the
application entering GameMode and never returning.
I would venture to guess that the developers of GLUT aren't particularly concerned with the behavior of GLUT after exiting game mode, because it's not a common thing to do in actual games. Additionally, GLUT is no longer maintained or updated, so oddities related specifically to hardware designed within the last ten years will likely go unfixed. GLUT isn't really suitable for production use; SDL, GLFW, or SFML are much more serviceable.
Clive McCarthy
Clive McCarthy
It is true that Glut itself has been frozen for a decade. However, Freeglut's last stable release 2.4.0 was June 2005 and they currently have a release candidate 2.6.0 that came out in April of _this_ year. So glut isn't quite as dead as you might imagine.

Glut remains the basis of most OpenGL tutorials. My own system has almost no user interaction & no sound so there is little reason to shift to a more modern framework, if the old one is in reasonable shape.

Thanks for the suggestions.



Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.