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; }
/* CENTRY */ int GLUTAPIENTRY glutCreateWindow(const char *title) { static int firstWindow = 1; GLUTwindow *window; #if !defined(_WIN32) && !defined(__OS2__) XWMHints *wmHints; #endif Window win; XTextProperty textprop; if (__glutGameModeWindow) { __glutFatalError("cannot create windows in game mode."); } window = __glutCreateWindow(NULL, __glutSizeHints.x, __glutSizeHints.y, __glutInitWidth, __glutInitHeight, /* not game mode */ 0); win = window->win; /* Setup ICCCM properties. */ textprop.value = (unsigned char *) title; textprop.encoding = XA_STRING; textprop.format = 8; textprop.nitems = strlen(title); #if defined(__OS2__) WinSetWindowText(window->frame, (PCSZ)title); if (__glutIconic) { window->desiredMapState = IconicState; } #elif defined(_WIN32) SetWindowText(win, title); if (__glutIconic) { window->desiredMapState = IconicState; } #else wmHints = XAllocWMHints(); wmHints->initial_state = __glutIconic ? IconicState : NormalState; wmHints->flags = StateHint; XSetWMProperties(__glutDisplay, win, &textprop, &textprop, /* Only put WM_COMMAND property on first window. */ firstWindow ? __glutArgv : NULL, firstWindow ? __glutArgc : 0, &__glutSizeHints, wmHints, NULL); XFree(wmHints); XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1); #endif firstWindow = 0; return window->num + 1; }
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 */ int GLUTAPIENTRY glutCreateWindow(const char *title) { static int firstWindow = 1; GLUTwindow *window; #if !defined(_WIN32) XWMHints *wmHints; #endif Window win; XTextProperty textprop; const char **pvalue = (const char**) &textprop.value; // See below for why... if (__glutGameModeWindow) { __glutFatalError("cannot create windows in game mode."); } window = __glutCreateWindow(NULL, __glutSizeHints.x, __glutSizeHints.y, __glutInitWidth, __glutInitHeight, /* not game mode */ 0); win = window->win; /* Setup ICCCM properties. */ *pvalue = title; /* We want to write "textprop.value = (unsigned char *) title;" but gcc complains about discarding const-ness of pointer */ assert(!strcmp((const char*)textprop.value, title)); textprop.encoding = XA_STRING; textprop.format = 8; textprop.nitems = (unsigned long)strlen(title); #if defined(_WIN32) SetWindowText(win, title); if (__glutIconic) { window->desiredMapState = IconicState; } #else wmHints = XAllocWMHints(); wmHints->initial_state = __glutIconic ? IconicState : NormalState; wmHints->flags = StateHint; XSetWMProperties(__glutDisplay, win, &textprop, &textprop, /* Only put WM_COMMAND property on first window. */ firstWindow ? __glutArgv : NULL, firstWindow ? __glutArgc : 0, &__glutSizeHints, wmHints, NULL); XFree(wmHints); XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1); #endif firstWindow = 0; return window->num + 1; }
int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height) { GLUTwindow *window; window = __glutCreateWindow(__glutWindowList[win - 1], x, y, width, height, /* not game mode */ 0); #if !defined(_WIN32) && !defined(__OS2__) { GLUTwindow *toplevel; toplevel = __glutToplevelOf(window); if (toplevel->cmap != window->cmap) { __glutPutOnWorkList(toplevel, GLUT_COLORMAP_WORK); } } #endif return window->num + 1; }
/* CENTRY */ int APIENTRY glutCreateWindow(const char *title) { static int firstWindow = 1; GLUTwindow *window; #if !defined(WIN32) XWMHints *wmHints; #endif Window win; XTextProperty textprop; window = __glutCreateWindow(NULL, __glutSizeHints.x, __glutSizeHints.y, __glutInitWidth, __glutInitHeight); win = window->win; /* Setup ICCCM properties. */ textprop.value = (unsigned char *) title; textprop.encoding = XA_STRING; textprop.format = 8; textprop.nitems = strlen(title); #if defined(WIN32) SetWindowText(win, title); if (__glutIconic) ShowWindow(win, SW_MINIMIZE); #else wmHints = XAllocWMHints(); wmHints->initial_state = __glutIconic ? IconicState : NormalState; wmHints->flags = StateHint; XSetWMProperties(__glutDisplay, win, &textprop, &textprop, /* Only put WM_COMMAND property on first window. */ firstWindow ? __glutArgv : NULL, firstWindow ? __glutArgc : 0, &__glutSizeHints, wmHints, NULL); XFree(wmHints); XSetWMProtocols(__glutDisplay, win, &__glutWMDeleteWindow, 1); #endif firstWindow = 0; return window->num + 1; }
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; }