diff --git a/examples/boing.c b/examples/boing.c index a2094c5f..8dc6ac95 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -581,7 +581,7 @@ int main( void ) glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwCreateWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL ); + window = glfwCreateWindow( 400, 400, "Boing (classic Amiga demo)", NULL, NULL ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/gears.c b/examples/gears.c index cd3cdbb1..d5d93251 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -345,7 +345,7 @@ int main(int argc, char *argv[]) glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL ); + window = glfwCreateWindow( 300, 300, "Gears", NULL, NULL ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/heightmap.c b/examples/heightmap.c index 5139a493..43f8da8a 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -587,7 +587,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); - window = glfwCreateWindow(800, 600, GLFW_WINDOWED, "GLFW OpenGL3 Heightmap demo", NULL); + window = glfwCreateWindow(800, 600, "GLFW OpenGL3 Heightmap demo", NULL, NULL); if (! window ) { fprintf(stderr, "ERROR: Unable to create the OpenGL context and associated window\n"); diff --git a/examples/splitview.c b/examples/splitview.c index 4a48a383..86339e4e 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -459,7 +459,7 @@ int main(void) glfwWindowHint(GLFW_DEPTH_BITS, 16); // Open OpenGL window - window = glfwCreateWindow(500, 500, GLFW_WINDOWED, "Split view demo", NULL); + window = glfwCreateWindow(500, 500, "Split view demo", NULL, NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window\n"); diff --git a/examples/triangle.c b/examples/triangle.c index 615483a9..6d15c7b3 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -23,7 +23,7 @@ int main(void) } // Open a window and create its OpenGL context - window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Spinning Triangle", NULL); + window = glfwCreateWindow(640, 480, "Spinning Triangle", NULL, NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window\n"); diff --git a/examples/wave.c b/examples/wave.c index 668d54bd..3dfce8ef 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -406,7 +406,7 @@ int main(int argc, char* argv[]) glfwSetCursorPosCallback(cursor_position_callback); glfwSetScrollCallback(scroll_callback); - window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL); + window = glfwCreateWindow(640, 480, "Wave Simulation", NULL, NULL); if (!window) { fprintf(stderr, "Could not open window\n"); diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 979c0650..94ceaf87 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -375,10 +375,6 @@ extern "C" { * Other definitions *************************************************************************/ -/* glfwCreateWindow modes */ -#define GLFW_WINDOWED 0x00010001 -#define GLFW_FULLSCREEN 0x00010002 - /* glfwGetWindowParam tokens */ #define GLFW_ACTIVE 0x00020001 #define GLFW_ICONIFIED 0x00020002 @@ -548,7 +544,7 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp); /* Window handling */ GLFWAPI void glfwWindowHint(int target, int hint); -GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share); +GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, const char* title, GLFWmonitor monitor, GLFWwindow share); GLFWAPI void glfwDestroyWindow(GLFWwindow window); GLFWAPI void glfwSetWindowTitle(GLFWwindow window, const char* title); GLFWAPI void glfwGetWindowSize(GLFWwindow window, int* width, int* height); diff --git a/readme.html b/readme.html index bb745470..95cd2472 100644 --- a/readme.html +++ b/readme.html @@ -297,7 +297,6 @@ version of GLFW.

  • Changed glfwGetVideoModes to return a dynamic, unlimited number of video modes
  • Renamed glfw.h to glfw3.h to avoid conflicts with 2.x series
  • Renamed glfwOpenWindowHint to glfwWindowHint
  • -
  • Renamed GLFW_WINDOW token to GLFW_WINDOWED
  • Renamed GLFW_WINDOW_NO_RESIZE to GLFW_RESIZABLE
  • Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL
  • Renamed version test to glfwinfo
  • @@ -322,6 +321,7 @@ version of GLFW.

  • Removed glfwGetNumberOfProcessors function
  • Removed glfwGetGLVersion function
  • Removed GLFW_OPENED window parameter
  • +
  • Removed GLFW_WINDOW and GLFW_FULLSCREEN
  • Removed nonsensical key actions for Unicode character input
  • Removed GLFWCALL and GLFWAPIENTRY macros for stdcall calling convention
  • Removed GLFW_ACCELERATED window parameter
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index efdc0c6b..844175f6 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -674,7 +674,9 @@ static GLboolean createWindow(_GLFWwindow* window, { unsigned int styleMask = 0; - if (wndconfig->mode == GLFW_WINDOWED) + if (wndconfig->monitor) + styleMask = NSBorderlessWindowMask; + else { styleMask = NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask; @@ -682,8 +684,6 @@ static GLboolean createWindow(_GLFWwindow* window, if (wndconfig->resizable) styleMask |= NSResizableWindowMask; } - else - styleMask = NSBorderlessWindowMask; window->NS.object = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, window->width, window->height) @@ -788,7 +788,7 @@ static GLboolean createContext(_GLFWwindow* window, ADD_ATTR(NSOpenGLPFADoubleBuffer); - if (wndconfig->mode == GLFW_FULLSCREEN) + if (wndconfig->monitor) { ADD_ATTR(NSOpenGLPFANoRecovery); ADD_ATTR2(NSOpenGLPFAScreenMask, @@ -919,7 +919,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, [window->NSGL.context setView:[window->NS.object contentView]]; - if (wndconfig->mode == GLFW_FULLSCREEN) + if (wndconfig->monitor) { int bpp = colorBits + fbconfig->alphaBits; @@ -952,7 +952,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) { [window->NS.object orderOut:nil]; - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { [[window->NS.object contentView] exitFullScreenModeWithOptions:nil]; @@ -1121,7 +1121,7 @@ void _glfwPlatformWaitEvents( void ) void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y) { - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { CGPoint globalPoint = CGPointMake(x, y); CGDisplayMoveCursorToPoint(CGMainDisplayID(), globalPoint); diff --git a/src/internal.h b/src/internal.h index b01707f9..2b702263 100755 --- a/src/internal.h +++ b/src/internal.h @@ -129,6 +129,7 @@ struct _GLFWwndconfig GLboolean glDebug; int glProfile; int glRobustness; + _GLFWmonitor* monitor; _GLFWwindow* share; }; @@ -176,6 +177,7 @@ struct _GLFWwindow GLboolean visible; // GL_TRUE if this window is visible int refreshRate; // monitor refresh rate void* userPointer; + _GLFWmonitor* monitor; // Window input state GLboolean stickyKeys; diff --git a/src/monitor.c b/src/monitor.c index 990e375f..e0b5e489 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -156,12 +156,20 @@ void _glfwInputMonitorChange(void) for (i = 0; i < _glfwLibrary.monitorCount; i++) { + _GLFWwindow* window; + if (_glfwLibrary.monitors[i] == NULL) continue; // This monitor is no longer connected _glfwLibrary.monitorCallback(_glfwLibrary.monitors[i], GLFW_MONITOR_DISCONNECTED); + + for (window = _glfwLibrary.windowListHead; window; window = window->next) + { + if (window->monitor == _glfwLibrary.monitors[i]) + window->monitor = NULL; + } } _glfwDestroyMonitors(); diff --git a/src/win32_window.c b/src/win32_window.c index 0b753db1..d98978be 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -344,7 +344,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode == GLFW_CURSOR_CAPTURED) showCursor(window); - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { if (!iconified) { @@ -367,7 +367,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, if (window->cursorMode == GLFW_CURSOR_CAPTURED) captureCursor(window); - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { if (!_glfwLibrary.Win32.monitor.modeChanged) { @@ -400,7 +400,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case SC_SCREENSAVE: case SC_MONITORPOWER: { - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { // We are running in fullscreen mode, so disallow // screen saver and screen blanking @@ -738,7 +738,7 @@ static int createWindow(_GLFWwindow* window, dwExStyle = WS_EX_APPWINDOW; // Set window style, depending on fullscreen mode - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { dwStyle |= WS_POPUP; @@ -775,7 +775,7 @@ static int createWindow(_GLFWwindow* window, // Adjust window position to working area (e.g. if the task bar is at // the top of the display). Fullscreen windows are always opened in // the upper left corner regardless of the desktop working area. - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) wa.left = wa.top = 0; else SystemParametersInfo(SPI_GETWORKAREA, 0, &wa, 0); @@ -866,7 +866,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GL_FALSE; } - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { int bpp = fbconfig->redBits + fbconfig->greenBits + fbconfig->blueBits; if (bpp < 15 || bpp >= 24) @@ -962,7 +962,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, return GL_FALSE; } - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { // Place the window above all topmost windows _glfwPlatformShowWindow(window); @@ -982,7 +982,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window) { destroyWindow(window); - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { if (_glfwLibrary.Win32.monitor.modeChanged) { @@ -1021,7 +1021,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) { GLboolean sizeChanged = GL_FALSE; - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { if (width > window->width || height > window->height) { diff --git a/src/window.c b/src/window.c index f27fbef9..3da4936d 100644 --- a/src/window.c +++ b/src/window.c @@ -224,7 +224,8 @@ void _glfwInputWindowCloseRequest(_GLFWwindow* window) //======================================================================== GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, - int mode, const char* title, + const char* title, + GLFWmonitor monitor, GLFWwindow share) { _GLFWfbconfig fbconfig; @@ -257,7 +258,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, fbconfig.samples = Max(_glfwLibrary.hints.samples, 0); // Set up desired window config - wndconfig.mode = mode; wndconfig.title = title; wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0); wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE; @@ -268,6 +268,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE; wndconfig.glProfile = _glfwLibrary.hints.glProfile; wndconfig.glRobustness = _glfwLibrary.hints.glRobustness ? GL_TRUE : GL_FALSE; + wndconfig.monitor = (_GLFWmonitor*) monitor; wndconfig.share = share; // Reset to default values for the next call @@ -280,13 +281,6 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, // Save the currently current context so it can be restored later previous = glfwGetCurrentContext(); - if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) - { - _glfwSetError(GLFW_INVALID_ENUM, - "glfwCreateWindow: Invalid window mode"); - return GL_FALSE; - } - // Check width & height if (width > 0 && height <= 0) { @@ -320,10 +314,10 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, // Remember window settings window->width = width; window->height = height; - window->mode = mode; window->resizable = wndconfig.resizable; window->cursorMode = GLFW_CURSOR_NORMAL; window->systemKeys = GL_TRUE; + window->monitor = (_GLFWmonitor*) monitor; // Open the actual window and create its context if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig)) @@ -364,10 +358,10 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, // The GLFW specification states that fullscreen windows have the cursor // captured by default - if (mode == GLFW_FULLSCREEN) + if (wndconfig.monitor) glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED); - if (mode == GLFW_WINDOWED && wndconfig.visible) + if (wndconfig.monitor == NULL && wndconfig.visible) glfwShowWindow(window); return window; @@ -570,7 +564,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height) _glfwPlatformSetWindowSize(window, width, height); - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { // Refresh window parameters (may have changed due to changed video // modes) @@ -615,7 +609,7 @@ GLFWAPI void glfwSetWindowPos(GLFWwindow handle, int xpos, int ypos) return; } - if (window->mode == GLFW_FULLSCREEN || window->iconified) + if (window->monitor || window->iconified) { // TODO: Figure out if this is an error return; @@ -665,7 +659,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle) _glfwPlatformRestoreWindow(window); - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) _glfwPlatformRefreshWindowParams(window); } @@ -684,7 +678,7 @@ GLFWAPI void glfwShowWindow(GLFWwindow handle) return; } - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) return; _glfwPlatformShowWindow(window); @@ -705,7 +699,7 @@ GLFWAPI void glfwHideWindow(GLFWwindow handle) return; } - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) return; _glfwPlatformHideWindow(window); diff --git a/src/x11_window.c b/src/x11_window.c index 9c1ff8d2..fe4ca705 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -107,7 +107,7 @@ static GLboolean createWindow(_GLFWwindow* window, ExposureMask | FocusChangeMask | VisibilityChangeMask | EnterWindowMask | LeaveWindowMask; - if (wndconfig->mode == GLFW_WINDOWED) + if (!wndconfig->monitor) { // The /only/ reason for setting the background pixel here is that // otherwise our window won't get any decorations on systems using @@ -138,7 +138,7 @@ static GLboolean createWindow(_GLFWwindow* window, } } - if (window->mode == GLFW_FULLSCREEN && !_glfwLibrary.X11.hasEWMH) + if (window->monitor && !_glfwLibrary.X11.hasEWMH) { // This is the butcher's way of removing window decorations // Setting the override-redirect attribute on a window makes the window @@ -851,7 +851,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, } #endif /*_GLFW_HAS_XRANDR*/ - if (wndconfig->mode == GLFW_FULLSCREEN) + if (wndconfig->monitor) { _glfwPlatformShowWindow(window); enterFullscreenMode(window); @@ -887,7 +887,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, void _glfwPlatformDestroyWindow(_GLFWwindow* window) { - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) leaveFullscreenMode(window); _glfwDestroyContext(window); @@ -959,7 +959,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) rate = window->refreshRate; - if (window->mode == GLFW_FULLSCREEN) + if (window->monitor) { // Get the closest matching video mode for the specified window size mode = _glfwGetClosestVideoMode(&width, &height, &rate); @@ -979,15 +979,17 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height) XFree(hints); } - // Change window size before changing fullscreen mode? - if (window->mode == GLFW_FULLSCREEN && (width > window->width)) + if (window->monitor) { - XResizeWindow(_glfwLibrary.X11.display, window->X11.handle, width, height); - sizeChanged = GL_TRUE; - } + // Change window size before changing fullscreen mode? + if (width > window->width) + { + XResizeWindow(_glfwLibrary.X11.display, + window->X11.handle, + width, height); + sizeChanged = GL_TRUE; + } - if (window->mode == GLFW_FULLSCREEN) - { // Change video mode, keeping current refresh rate _glfwSetVideoModeMODE(mode, window->refreshRate); } diff --git a/tests/accuracy.c b/tests/accuracy.c index f3fb752b..f9c485c9 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -90,7 +90,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); glfwSetKeyCallback(key_callback); - window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); + window = glfwCreateWindow(window_width, window_height, "", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/clipboard.c b/tests/clipboard.c index f83bbfea..eafce3f7 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -125,7 +125,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL); + window = glfwCreateWindow(0, 0, "Clipboard Test", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/defaults.c b/tests/defaults.c index 2877cfd9..113ff55e 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -85,7 +85,7 @@ int main(void) glfwWindowHint(GLFW_VISIBLE, GL_FALSE); - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL); + window = glfwCreateWindow(0, 0, "Defaults", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/events.c b/tests/events.c index f1e71f9a..f30fd5da 100644 --- a/tests/events.c +++ b/tests/events.c @@ -399,7 +399,7 @@ int main(void) glfwSetCharCallback(char_callback); glfwSetMonitorCallback(monitor_callback); - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL); + window = glfwCreateWindow(0, 0, "Event Linter", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/fsaa.c b/tests/fsaa.c index 8fc8b60a..060d0b7b 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -98,7 +98,7 @@ int main(int argc, char** argv) glfwWindowHint(GLFW_FSAA_SAMPLES, samples); - window = glfwCreateWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); + window = glfwCreateWindow(800, 400, "Aliasing Detector", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/fsfocus.c b/tests/fsfocus.c index 6ae0cb45..a00e4fa4 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -82,7 +82,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL); + window = glfwCreateWindow(640, 480, "Fullscreen focus", glfwGetPrimaryMonitor(), NULL); if (!window) { glfwTerminate(); diff --git a/tests/gamma.c b/tests/gamma.c index 82d9de96..aaed81d9 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -97,7 +97,7 @@ static void size_callback(GLFWwindow window, int width, int height) int main(int argc, char** argv) { int width, height, ch; - int mode = GLFW_WINDOWED; + GLFWmonitor monitor = NULL; GLFWwindow window; while ((ch = getopt(argc, argv, "fh")) != -1) @@ -109,7 +109,7 @@ int main(int argc, char** argv) exit(EXIT_SUCCESS); case 'f': - mode = GLFW_FULLSCREEN; + monitor = glfwGetPrimaryMonitor(); break; default: @@ -124,10 +124,10 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - if (mode == GLFW_FULLSCREEN) + if (monitor) { GLFWvidmode mode; - glfwGetVideoMode(glfwGetPrimaryMonitor(), &mode); + glfwGetVideoMode(monitor, &mode); width = mode.width; height = mode.height; } @@ -137,7 +137,7 @@ int main(int argc, char** argv) height = 0; } - window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL); + window = glfwCreateWindow(width, height, "Gamma Test", monitor, NULL); if (!window) { glfwTerminate(); diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index d11c861d..be899caf 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -243,7 +243,7 @@ int main(int argc, char** argv) // We assume here that we stand a better chance of success by leaving all // possible details of pixel format selection to GLFW - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL); + window = glfwCreateWindow(0, 0, "Version", NULL, NULL); if (!window) exit(EXIT_FAILURE); diff --git a/tests/iconify.c b/tests/iconify.c index b96368e5..b76a83b3 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -78,8 +78,8 @@ static void window_size_callback(GLFWwindow window, int width, int height) int main(int argc, char** argv) { int width, height, ch; - int mode = GLFW_WINDOWED; GLboolean active = -1, iconified = -1; + GLFWmonitor monitor = NULL; GLFWwindow window; while ((ch = getopt(argc, argv, "fh")) != -1) @@ -91,7 +91,7 @@ int main(int argc, char** argv) exit(EXIT_SUCCESS); case 'f': - mode = GLFW_FULLSCREEN; + monitor = glfwGetPrimaryMonitor(); break; default: @@ -106,12 +106,12 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - if (mode == GLFW_FULLSCREEN) + if (monitor) { - GLFWvidmode current_mode; - glfwGetVideoMode(glfwGetPrimaryMonitor(), ¤t_mode); - width = current_mode.width; - height = current_mode.height; + GLFWvidmode mode; + glfwGetVideoMode(monitor, &mode); + width = mode.width; + height = mode.height; } else { @@ -119,7 +119,7 @@ int main(int argc, char** argv) height = 0; } - window = glfwCreateWindow(width, height, mode, "Iconify", NULL); + window = glfwCreateWindow(width, height, "Iconify", monitor, NULL); if (!window) { glfwTerminate(); diff --git a/tests/joysticks.c b/tests/joysticks.c index 40202ce7..78bcb702 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -186,7 +186,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL); + window = glfwCreateWindow(0, 0, "Joystick Test", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/modes.c b/tests/modes.c index f2065292..abb30337 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -144,7 +144,8 @@ static void test_modes(GLFWmonitor monitor) format_mode(mode)); window_handle = glfwCreateWindow(mode->width, mode->height, - GLFW_FULLSCREEN, "Video Mode Test", + "Video Mode Test", + glfwGetPrimaryMonitor(), NULL); if (!window_handle) { diff --git a/tests/peter.c b/tests/peter.c index 59c917e9..6515d2e4 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -92,7 +92,7 @@ static void window_size_callback(GLFWwindow window, int width, int height) static GLboolean open_window(void) { - window_handle = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL); + window_handle = glfwCreateWindow(0, 0, "Peter Detector", NULL, NULL); if (!window_handle) return GL_FALSE; diff --git a/tests/reopen.c b/tests/reopen.c index 5d137188..c095424e 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -41,19 +41,6 @@ static GLFWwindow window_handle = NULL; static GLboolean closed = GL_FALSE; -static const char* get_mode_name(int mode) -{ - switch (mode) - { - case GLFW_WINDOWED: - return "windowed"; - case GLFW_FULLSCREEN: - return "fullscreen"; - default: - return "unknown"; - } -} - static void window_size_callback(GLFWwindow window, int width, int height) { glViewport(0, 0, width, height); @@ -80,22 +67,18 @@ static void key_callback(GLFWwindow window, int key, int action) } } -static GLboolean open_window(int width, int height, int mode) +static GLboolean open_window(int width, int height, GLFWmonitor monitor) { double base; - if (!glfwInit()) - { - fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); - return GL_FALSE; - } - base = glfwGetTime(); - window_handle = glfwCreateWindow(width, height, mode, "Window Re-opener", NULL); + window_handle = glfwCreateWindow(width, height, "Window Re-opener", monitor, NULL); if (!window_handle) { - fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError())); + fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", + monitor ? "fullscreen" : "windowed", + glfwErrorString(glfwGetError())); return GL_FALSE; } @@ -107,7 +90,7 @@ static GLboolean open_window(int width, int height, int mode) glfwSetKeyCallback(key_callback); printf("Opening %s mode window took %0.3f seconds\n", - get_mode_name(mode), + monitor ? "fullscreen" : "windowed", glfwGetTime() - base); return GL_TRUE; @@ -121,17 +104,26 @@ static void close_window(void) window_handle = NULL; printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); - - glfwTerminate(); } int main(int argc, char** argv) { int count = 0; + if (!glfwInit()) + { + fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError())); + return GL_FALSE; + } + for (;;) { - if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED)) + GLFWmonitor monitor = NULL; + + if (count & 1) + monitor = glfwGetPrimaryMonitor(); + + if (!open_window(640, 480, monitor)) exit(EXIT_FAILURE); glMatrixMode(GL_PROJECTION); diff --git a/tests/sharing.c b/tests/sharing.c index 64e61740..6989105b 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -55,7 +55,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) { GLFWwindow window; - window = glfwCreateWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share); + window = glfwCreateWindow(WIDTH, HEIGHT, title, NULL, share); if (!window) return NULL; diff --git a/tests/tearing.c b/tests/tearing.c index a8d774a4..734b96c8 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -70,7 +70,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL); + window = glfwCreateWindow(0, 0, "", NULL, NULL); if (!window) { glfwTerminate(); diff --git a/tests/threads.c b/tests/threads.c index 49e3739a..9063cfe6 100644 --- a/tests/threads.c +++ b/tests/threads.c @@ -90,9 +90,8 @@ int main(void) for (i = 0; i < count; i++) { threads[i].window = glfwCreateWindow(200, 200, - GLFW_WINDOWED, threads[i].title, - NULL); + NULL, NULL); if (!threads[i].window) { fprintf(stderr, "Failed to open GLFW window: %s\n", diff --git a/tests/title.c b/tests/title.c index c7539033..b151d751 100644 --- a/tests/title.c +++ b/tests/title.c @@ -47,7 +47,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); + window = glfwCreateWindow(0, 0, "English 日本語 русский язык 官話", NULL, NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError())); diff --git a/tests/windows.c b/tests/windows.c index 894febeb..46481dfb 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -55,7 +55,7 @@ int main(void) for (i = 0; i < 4; i++) { - windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL); + windows[i] = glfwCreateWindow(200, 200, titles[i], NULL, NULL); if (!windows[i]) { fprintf(stderr, "Failed to open GLFW window: %s\n",