void __glutSetWindow(GLUTwindow * window) { /* It is tempting to try to short-circuit the call to glXMakeCurrent if we "know" we are going to make current to a window we are already current to. In fact, this assumption breaks when GLUT is expected to integrated with other OpenGL windowing APIs that also make current to OpenGL contexts. Since glXMakeCurrent short-circuits the "already bound" case, GLUT avoids the temptation to do so too. */ __glutCurrentWindow = window; MAKE_CURRENT_LAYER(__glutCurrentWindow); #if !defined(_WIN32) && !defined(__OS2__) /* We should be careful to force a finish between each iteration through the GLUT main loop if indirect OpenGL contexts are in use; indirect contexts tend to have much longer latency because lots of OpenGL extension requests can queue up in the X protocol stream. We accomplish this by posting GLUT_FINISH_WORK to be done. */ if (!__glutCurrentWindow->isDirect) __glutPutOnWorkList(__glutCurrentWindow, GLUT_FINISH_WORK); #endif /* If debugging is enabled, we'll want to check this window for any OpenGL errors every iteration through the GLUT main loop. To accomplish this, we post the GLUT_DEBUG_WORK to be done on this window. */ if (__glutDebug) { __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEBUG_WORK); } }
void APIENTRY glutPushWindow(void) { __glutCurrentWindow->desiredStack = Below; __glutCurrentWindow->desiredConfMask |= CWStackMode; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK); }
void GLUTAPIENTRY glutHideWindow(void) { IGNORE_IN_GAME_MODE(); __glutCurrentWindow->desiredMapState = WithdrawnState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }
void GLUTAPIENTRY glutShowWindow(void) { IGNORE_IN_GAME_MODE(); __glutCurrentWindow->desiredMapState = NormalState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }
/* CENTRY */ void APIENTRY glutFullScreen(void) { assert(!__glutCurrentWindow->parent); IGNORE_IN_GAME_MODE(); #if !defined(_WIN32) if (__glutMotifHints == None) { __glutMotifHints = XSGIFastInternAtom(__glutDisplay, "_MOTIF_WM_HINTS", SGI_XA__MOTIF_WM_HINTS, 0); if (__glutMotifHints == None) { __glutWarning("Could not intern X atom for _MOTIF_WM_HINTS."); } } #endif __glutCurrentWindow->desiredX = 0; __glutCurrentWindow->desiredY = 0; __glutCurrentWindow->desiredWidth = __glutScreenWidth; __glutCurrentWindow->desiredHeight = __glutScreenHeight; __glutCurrentWindow->desiredConfMask |= CWX | CWY | CWWidth | CWHeight; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK); }
void APIENTRY glutIconifyWindow(void) { assert(!__glutCurrentWindow->parent); __glutCurrentWindow->desiredMapState = IconicState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }
void GLUTAPIENTRY glutPushWindow(void) { IGNORE_IN_GAME_MODE(); __glutCurrentWindow->desiredStack = Below; __glutCurrentWindow->desiredConfMask |= CWStackMode; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK); }
void GLUTAPIENTRY glutIconifyWindow(void) { IGNORE_IN_GAME_MODE(); assert(!__glutCurrentWindow->parent); __glutCurrentWindow->desiredMapState = IconicState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }
void APIENTRY glutPositionWindow(int x, int y) { __glutCurrentWindow->desiredX = x; __glutCurrentWindow->desiredY = y; __glutCurrentWindow->desiredConfMask |= CWX | CWY; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK); }
void glutDialsFunc(GLUTdialsCB dialsFunc) { __glutCurrentWindow->dials = dialsFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); }
void glutSpaceballMotionFunc(GLUTspaceMotionCB spaceMotionFunc) { __glutCurrentWindow->spaceMotion = spaceMotionFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); }
void GLUTAPIENTRY glutTabletButtonFunc(GLUTtabletButtonCB tabletButtonFunc) { __glutCurrentWindow->tabletButton = tabletButtonFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); }
void GLUTAPIENTRY glutSpaceballRotateFunc(GLUTspaceRotateCB spaceRotateFunc) { __glutCurrentWindow->spaceRotate = spaceRotateFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); }
void glutButtonBoxFunc(GLUTbuttonBoxCB buttonBoxFunc) { __glutCurrentWindow->buttonBox = buttonBoxFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); }
void __glutChangeWindowEventMask(long eventMask, Bool add) { if (add) { /* Add eventMask to window's event mask. */ if ((__glutCurrentWindow->eventMask & eventMask) != eventMask) { __glutCurrentWindow->eventMask |= eventMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_EVENT_MASK_WORK); } } else { /* Remove eventMask from window's event mask. */ if (__glutCurrentWindow->eventMask & eventMask) { __glutCurrentWindow->eventMask &= ~eventMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_EVENT_MASK_WORK); } } }
void GLUTAPIENTRY glutReshapeWindow(int w, int h) { IGNORE_IN_GAME_MODE(); if (w <= 0 || h <= 0) __glutWarning("glutReshapeWindow: non-positive width or height not allowed"); __glutCurrentWindow->desiredWidth = w; __glutCurrentWindow->desiredHeight = h; __glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK); }
void GLUTAPIENTRY glutTabletMotionFunc(GLUTtabletMotionCB tabletMotionFunc) { __glutCurrentWindow->tabletMotion = tabletMotionFunc; __glutUpdateInputDeviceMaskFunc = __glutUpdateInputDeviceMask; __glutPutOnWorkList(__glutCurrentWindow, GLUT_DEVICE_MASK_WORK); /* If deinstalling callback, invalidate tablet position. */ if (tabletMotionFunc == NULL) { __glutCurrentWindow->tabletPos[0] = -1; __glutCurrentWindow->tabletPos[1] = -1; } }
void __glutPostRedisplay(GLUTwindow * window, int layerMask) { int shown = (layerMask & (GLUT_REDISPLAY_WORK | GLUT_REPAIR_WORK)) ? window->shownState : window->overlay->shownState; /* Post a redisplay if the window is visible (or the visibility of the window is unknown, ie. window->visState == -1) _and_ the layer is known to be shown. */ if (window->visState != GLUT_HIDDEN && window->visState != GLUT_FULLY_COVERED && shown) { __glutPutOnWorkList(window, layerMask); } }
void glutFullScreen(void) { if (__glutMotifHints == None) { __glutMotifHints = XInternAtom(__glutDisplay, "_MOTIF_WM_HINTS", 0); if (__glutMotifHints == None) { __glutWarning("Could not intern X atom for WM_COLORMAP_WINDOWS."); } } __glutCurrentWindow->desiredX = 0; __glutCurrentWindow->desiredY = 0; __glutCurrentWindow->desiredWidth = __glutScreenWidth; __glutCurrentWindow->desiredHeight = __glutScreenHeight; __glutCurrentWindow->desiredConfMask |= CWX | CWY | CWWidth | CWHeight; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK | GLUT_FULL_SCREEN_WORK); }
void APIENTRY glutReshapeWindow(int w, int h) { if (w <= 0 || h <= 0) __glutWarning("glutReshapeWindow: non-positive width or height not allowed"); #if defined(WIN32) if (w < __glutMinWindowWidth && !__glutCurrentWindow->parent) __glutWarning("requested width is less than minimum allowed."); if (h < __glutMinWindowHeight && !__glutCurrentWindow->parent) __glutWarning("requested height is less than minimum allowed."); #endif /* WIN32 */ __glutCurrentWindow->desiredWidth = w; __glutCurrentWindow->desiredHeight = h; __glutCurrentWindow->desiredConfMask |= CWWidth | CWHeight; __glutPutOnWorkList(__glutCurrentWindow, GLUT_CONFIGURE_WORK); }
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 */ 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 APIENTRY glutShowWindow(void) { __glutCurrentWindow->desiredMapState = NormalState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }
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; }
void APIENTRY glutHideWindow(void) { __glutCurrentWindow->desiredMapState = WithdrawnState; __glutPutOnWorkList(__glutCurrentWindow, GLUT_MAP_WORK); }