void __glutDestroyWindow(GLUTwindow * window, GLUTwindow * initialWindow) { GLUTwindow **prev, *cur, *parent, *siblings; /* Recursively destroy any children. */ cur = window->children; while (cur) { siblings = cur->siblings; __glutDestroyWindow(cur, initialWindow); cur = siblings; } /* Remove from parent's children list (only necessary for non-initial windows and subwindows!). */ parent = window->parent; if (parent && parent == initialWindow->parent) { prev = &parent->children; cur = parent->children; while (cur) { if (cur == window) { *prev = cur->siblings; break; } prev = &(cur->siblings); cur = cur->siblings; } } /* Unbind if bound to this window. */ if (window == __glutCurrentWindow) { glXMakeCurrent(__glutDisplay, None, NULL); __glutCurrentWindow = NULL; } /* Begin tearing down window itself. */ if (window->overlay) { __glutFreeOverlayFunc(window->overlay); } XDestroyWindow(__glutDisplay, window->win); glXDestroyContext(__glutDisplay, window->ctx); if (window->colormap) { /* Only color index windows have colormap data structure. */ __glutFreeColormap(window->colormap); } /* NULLing the __glutWindowList helps detect is a window instance has been destroyed, given a window number. */ __glutWindowList[window->num] = NULL; /* Cleanup data structures that might contain window. */ cleanWindowWorkList(window); cleanStaleWindowList(window); /* Remove window from the "get window cache" if it is there. */ if (__glutWindowCache == window) __glutWindowCache = NULL; if (window->visAlloced) { /* Only free XVisualInfo* gotten from glXChooseVisual. */ XFree(window->vis); } free(window); }
int GLUTAPIENTRY glutEnterGameMode( void ) { DFBDisplayLayerConfig prev, cur; glutInit( NULL, NULL ); primary->GetConfiguration( primary, &prev ); primary->SetCooperativeLevel( primary, DLSCL_EXCLUSIVE ); if (g_game) __glutDestroyWindow( g_game ); g_game = __glutCreateWindow( GL_TRUE ); if (!g_game) return 0; __glutSetWindow( g_game ); g_game->cursor = GLUT_CURSOR_NONE; primary->GetConfiguration( primary, &cur ); g_display_changed = (cur.width != prev.width || cur.height != prev.height || cur.pixelformat != prev.pixelformat); return g_game->id; }
void GLUTAPIENTRY glutLeaveGameMode( void ) { if (g_game) __glutDestroyWindow( g_game ); primary->SetCooperativeLevel( primary, DLSCL_ADMINISTRATIVE ); }
void GLUTAPIENTRY glutLeaveGameMode(void) { if (__glutGameModeWindow == NULL) { __glutWarning("not in game mode so cannot leave game mode"); return; } __glutDestroyWindow(__glutGameModeWindow, __glutGameModeWindow); XFlush(__glutDisplay); __glutGameModeWindow = NULL; }
static int ifSunCreator(void) { char *xvendor, *glvendor, *renderer; int isSunCreator = 0; /* Until proven that it is. */ int savedDisplayMode = 0; char *savedDisplayString = 0; GLUTwindow *window; #define VENDOR_SUN "Sun Microsystems" #define RENDERER_CREATOR "Creator" /* Check the X vendor string first. It is easier to check than the OpenGL vendor and renderer strings since it doesn't require a valid OpenGL rendering context. Bail early if not connected to a Sun. */ xvendor = ServerVendor(__glutDisplay); if (!strncmp(xvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) { /* We need a valid current OpenGL rendering context to be able to call glGetString successfully. If there is not a current window, set up a temporary one just to call glGetString with (gag, expensive). */ if (__glutCurrentWindow) { window = NULL; } else { savedDisplayMode = __glutDisplayMode; savedDisplayString = __glutDisplayString; __glutDisplayMode = GLUT_RGB | GLUT_SINGLE; __glutDisplayString = NULL; window = __glutCreateWindow(NULL, 0, 0, 1, 1, 0); } glvendor = (char *) glGetString(GL_VENDOR); if (!strncmp(glvendor, VENDOR_SUN, sizeof(VENDOR_SUN) - 1)) { renderer = (char *) glGetString(GL_RENDERER); if (!strncmp(renderer, RENDERER_CREATOR, sizeof(RENDERER_CREATOR) - 1)) { isSunCreator = 1; } } /* Destroy the temporary window for glGetString if one needed to be created. */ if (window) { __glutDestroyWindow(window, window); __glutDisplayMode = savedDisplayMode; __glutDisplayString = savedDisplayString; } } return isSunCreator; }
/* CENTRY */ void APIENTRY glutDestroyWindow(int win) { GLUTwindow *window = __glutWindowList[win - 1]; if (__glutMappedMenu && __glutMenuWindow == window) { __glutFatalUsage("destroying menu window not allowed while menus in use"); } #if !defined(WIN32) /* If not a toplevel window... */ if (window->parent) { /* Destroying subwindows may change colormap requirements; recalculate toplevel window's WM_COLORMAP_WINDOWS property. */ __glutPutOnWorkList(__glutToplevelOf(window->parent), GLUT_COLORMAP_WORK); } #endif __glutDestroyWindow(window, window); }
void __glutDestroyWindow(GLUTwindow * window, GLUTwindow * initialWindow) { GLUTwindow **prev, *cur, *parent, *siblings; /* Recursively destroy any children. */ cur = window->children; while (cur) { siblings = cur->siblings; __glutDestroyWindow(cur, initialWindow); cur = siblings; } /* Remove from parent's children list (only necessary for non-initial windows and subwindows!). */ parent = window->parent; if (parent && parent == initialWindow->parent) { prev = &parent->children; cur = parent->children; while (cur) { if (cur == window) { *prev = cur->siblings; break; } prev = &(cur->siblings); cur = cur->siblings; } } /* Unbind if bound to this window. */ if (window == __glutCurrentWindow) { UNMAKE_CURRENT(); __glutCurrentWindow = NULL; } /* Invalidate glutExtensionSupported string cache if needed. */ __glutInvalidateExtensionStringCacheIfNeeded(window->ctx); /* Begin tearing down window itself. */ if (window->overlay) { __glutInvalidateExtensionStringCacheIfNeeded(window->overlay->ctx); __glutFreeOverlayFunc(window->overlay); } XDestroyWindow(__glutDisplay, window->win); glXDestroyContext(__glutDisplay, window->ctx); if (window->colormap) { /* Only color index windows have colormap data structure. */ __glutFreeColormap(window->colormap); } /* NULLing the __glutWindowList helps detect is a window instance has been destroyed, given a window number. */ __glutWindowList[window->num] = NULL; /* Cleanup data structures that might contain window. */ cleanWindowWorkList(window); #if !defined(_WIN32) cleanStaleWindowList(window); #endif /* Remove window from the "get window cache" if it is there. */ if (__glutWindowCache == window) { __glutWindowCache = NULL; } if (window->visAlloced) { /* Only free XVisualInfo* gotten from glXChooseVisual. */ XFree(window->vis); } if (window == __glutGameModeWindow) { /* Destroying the game mode window should implicitly have GLUT leave game mode. */ __glutCloseDownGameMode(); } free(window); }
int GLUTAPIENTRY glutEnterGameMode(void) { GLUTwindow *window; int width, height; Window win; /* Initialize GLUT since glutInit may not have been called. */ #if defined(_WIN32) WNDCLASS wc; if (!GetClassInfo(GetModuleHandle(NULL), "GLUT", &wc)) { __glutOpenWin32Connection(NULL); } #else if (!__glutDisplay) { __glutOpenXConnection(NULL); } #endif if (__glutMappedMenu) { __glutFatalUsage("entering game mode not allowed while menus in use"); } if (__glutGameModeWindow) { /* Already in game mode, so blow away game mode window so apps can change resolutions. */ window = __glutGameModeWindow; /* Setting the game mode window to NULL tricks the window destroy code into not undoing the screen display change since we plan on immediately doing another mode change. */ __glutGameModeWindow = NULL; __glutDestroyWindow(window, window); } /* Assume default screen size until we find out if we can actually change the display settings. */ width = __glutScreenWidth; height = __glutScreenHeight; if (currentDm) { #ifdef _WIN32 LONG status; static int registered = 0; /* The Cygnus B20.1 tools do not have this defined. */ #ifndef CDS_FULLSCREEN #define CDS_FULLSCREEN 0x00000004 #endif status = ChangeDisplaySettings(¤tDm->devmode, CDS_FULLSCREEN); if (status == DISP_CHANGE_SUCCESSFUL) { __glutDisplaySettingsChanged = 1; width = currentDm->cap[DM_WIDTH]; height = currentDm->cap[DM_HEIGHT]; if (!registered) { atexit(__glutCloseDownGameMode); registered = 1; } } else { /* Switch back to default resolution. */ ChangeDisplaySettings(NULL, 0); } #endif } window = __glutCreateWindow(NULL, 0, 0, width, height, /* game mode */ 1); win = window->win; #if !defined(_WIN32) __glutMakeFullScreenAtoms(); /* Game mode window is a toplevel window. */ XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1); #endif /* Schedule the fullscreen property to be added and to make sure the window is configured right. Win32 doesn't need this. */ window->desiredX = 0; window->desiredY = 0; window->desiredWidth = width; window->desiredHeight = height; window->desiredConfMask |= CWX | CWY | CWWidth | CWHeight; #ifdef _WIN32 /* Win32 does not want to use GLUT_FULL_SCREEN_WORK for game mode because we need to be maximizing the window in game mode, not just sizing it to take up the full screen. The Win32-ness of game mode happens when you pass 1 in the gameMode parameter to __glutCreateWindow above. A gameMode of creates a WS_POPUP window, not a standard WS_OVERLAPPEDWINDOW window. WS_POPUP ensures the taskbar is hidden. */ __glutPutOnWorkList(window, GLUT_CONFIGURE_WORK); #else __glutPutOnWorkList(window, GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK); #endif __glutGameModeWindow = window; return window->num + 1; }