From 1736132bb2a4bdae9b64f8ff9d19bef61543723e Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 3 Aug 2012 15:21:49 +0200 Subject: [PATCH 01/29] Fixed window parameter refresh. --- src/cocoa_window.m | 2 +- src/internal.h | 2 +- src/win32_window.c | 3 +-- src/window.c | 11 ++++++----- src/x11_window.c | 4 +--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 74f187b0..2f6b851c 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1041,7 +1041,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) // Write back window parameters into GLFW window structure //======================================================================== -void _glfwPlatformRefreshWindowParams(void) +void _glfwPlatformRefreshWindowParams(_GLFWwindow* window) { } diff --git a/src/internal.h b/src/internal.h index 99d74b86..81eb26c6 100644 --- a/src/internal.h +++ b/src/internal.h @@ -326,7 +326,7 @@ void _glfwPlatformWaitEvents(void); void _glfwPlatformMakeContextCurrent(_GLFWwindow* window); void _glfwPlatformSwapBuffers(void); void _glfwPlatformSwapInterval(int interval); -void _glfwPlatformRefreshWindowParams(void); +void _glfwPlatformRefreshWindowParams(_GLFWwindow* window); int _glfwPlatformExtensionSupported(const char* extension); GLFWglproc _glfwPlatformGetProcAddress(const char* procname); void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask); diff --git a/src/win32_window.c b/src/win32_window.c index fff50ea2..aced1511 100755 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -1198,10 +1198,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) // Write back window parameters into GLFW window structure //======================================================================== -void _glfwPlatformRefreshWindowParams(void) +void _glfwPlatformRefreshWindowParams(_GLFWwindow* window) { DEVMODE dm; - _GLFWwindow* window = _glfwLibrary.currentWindow; ZeroMemory(&dm, sizeof(DEVMODE)); dm.dmSize = sizeof(DEVMODE); diff --git a/src/window.c b/src/window.c index 2e77fa15..27237329 100644 --- a/src/window.c +++ b/src/window.c @@ -318,17 +318,18 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, return GL_FALSE; } - // Cache the actual (as opposed to desired) window parameters - _glfwPlatformRefreshWindowParams(); + // Cache the actual (as opposed to requested) window parameters + _glfwPlatformRefreshWindowParams(window); + // Cache the actual (as opposed to requested) context parameters glfwMakeContextCurrent(window); - if (!_glfwRefreshContextParams()) { glfwCloseWindow(window); return GL_FALSE; } + // Verify the context against the requested parameters if (!_glfwIsValidContext(&wndconfig)) { glfwCloseWindow(window); @@ -573,7 +574,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height) { // Refresh window parameters (may have changed due to changed video // modes) - _glfwPlatformRefreshWindowParams(); + _glfwPlatformRefreshWindowParams(window); } } @@ -665,7 +666,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle) _glfwPlatformRestoreWindow(window); if (window->mode == GLFW_FULLSCREEN) - _glfwPlatformRefreshWindowParams(); + _glfwPlatformRefreshWindowParams(window); } diff --git a/src/x11_window.c b/src/x11_window.c index e5c548de..656c3735 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -1137,10 +1137,8 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window) // Read back framebuffer parameters from the context //======================================================================== -void _glfwPlatformRefreshWindowParams(void) +void _glfwPlatformRefreshWindowParams(_GLFWwindow* window) { - _GLFWwindow* window = _glfwLibrary.currentWindow; - // Retrieve refresh rate if possible if (_glfwLibrary.X11.RandR.available) { From 2972cdfeb1e7e5b77cb889aaf787896885917a09 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 3 Aug 2012 16:20:52 +0200 Subject: [PATCH 02/29] Removed glfwIsWindow. --- examples/boing.c | 17 +++++++++++++++-- examples/gears.c | 15 +++++++++------ examples/splitview.c | 21 +++++++++++++++++++-- examples/triangle.c | 16 ++++++++++++++-- examples/wave.c | 15 ++++++++++++--- include/GL/glfw3.h | 1 - readme.html | 1 - src/window.c | 28 ---------------------------- tests/accuracy.c | 2 +- tests/clipboard.c | 2 +- tests/events.c | 2 +- tests/fsaa.c | 2 +- tests/fsfocus.c | 3 ++- tests/gamma.c | 2 +- tests/iconify.c | 2 +- tests/joysticks.c | 3 +-- tests/peter.c | 2 +- tests/sharing.c | 22 ++++++++++++++++++++-- tests/tearing.c | 2 +- tests/title.c | 2 +- tests/windows.c | 17 ++++++++++------- 21 files changed, 111 insertions(+), 66 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 49d602ca..d3b34172 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -43,6 +43,7 @@ void init( void ); void display( void ); void reshape( GLFWwindow window, int w, int h ); +int window_close_callback(GLFWwindow window); void DrawBoingBall( void ); void BounceBall( double dt ); void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); @@ -89,6 +90,7 @@ DRAW_BALL_ENUM drawBallHow; double t; double t_old = 0.f; double dt; +static GLboolean running = GL_TRUE; /* Random number generator */ #ifndef RAND_MAX @@ -245,6 +247,16 @@ void reshape( GLFWwindow window, int w, int h ) } +/***************************************************************************** + * Window close callback + *****************************************************************************/ +int window_close_callback(GLFWwindow window) +{ + running = GL_FALSE; + return GL_TRUE; +} + + /***************************************************************************** * Draw the Boing ball. * @@ -567,7 +579,6 @@ void DrawGrid( void ) int main( void ) { - int running; GLFWwindow window; /* Init GLFW */ @@ -587,6 +598,7 @@ int main( void ) exit( EXIT_FAILURE ); } + glfwSetWindowCloseCallback( window_close_callback ); glfwSetWindowSizeCallback( reshape ); glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE ); glfwSwapInterval( 1 ); @@ -610,7 +622,8 @@ int main( void ) glfwPollEvents(); /* Check if we are still running */ - running = glfwIsWindow(window) && !glfwGetKey( window, GLFW_KEY_ESCAPE ); + if (glfwGetKey( window, GLFW_KEY_ESCAPE )) + running = GL_FALSE; } while( running ); diff --git a/examples/gears.c b/examples/gears.c index 53d601f3..4ce68ab6 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -267,6 +267,14 @@ void reshape( GLFWwindow window, int width, int height ) } +/* close callback */ +int window_close_callback(GLFWwindow window) +{ + running = 0; + return GL_TRUE; +} + + /* program & OpenGL initialization */ static void init(int argc, char *argv[]) { @@ -346,6 +354,7 @@ int main(int argc, char *argv[]) init(argc, argv); // Set callback functions + glfwSetWindowCloseCallback(window_close_callback); glfwSetWindowSizeCallback( reshape ); glfwSetKeyCallback( key ); @@ -361,12 +370,6 @@ int main(int argc, char *argv[]) // Swap buffers glfwSwapBuffers(); glfwPollEvents(); - - // Was the window closed? - if( !glfwIsWindow( window ) ) - { - running = 0; - } } // Terminate GLFW diff --git a/examples/splitview.c b/examples/splitview.c index c584f9af..d9595717 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -42,6 +42,9 @@ static int rot_x = 0, rot_y = 0, rot_z = 0; // Do redraw? static int do_redraw = 1; +// Keep running? +static GLboolean running = GL_TRUE; + //======================================================================== // Draw a solid torus (use a display list for the model) @@ -435,6 +438,17 @@ static void mouseButtonFun(GLFWwindow window, int button, int action) } +//======================================================================== +// Window close callback function +//======================================================================== + +static int windowCloseFun(GLFWwindow window) +{ + running = GL_FALSE; + return GL_TRUE; +} + + //======================================================================== // main //======================================================================== @@ -470,6 +484,7 @@ int main(void) glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); // Set callback functions + glfwSetWindowCloseCallback(windowCloseFun); glfwSetWindowSizeCallback(windowSizeFun); glfwSetWindowRefreshCallback(windowRefreshFun); glfwSetCursorPosCallback(cursorPosFun); @@ -493,9 +508,11 @@ int main(void) // Wait for new events glfwWaitEvents(); + if (glfwGetKey(window, GLFW_KEY_ESCAPE)) + running = GL_FALSE; + } // Check if the ESC key was pressed or the window was closed - while (glfwIsWindow(window) && - glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS); + while (running); // Close OpenGL window and terminate GLFW glfwTerminate(); diff --git a/examples/triangle.c b/examples/triangle.c index ee340496..bf26a94e 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -10,6 +10,14 @@ #define GLFW_INCLUDE_GLU #include +static GLboolean running = GL_TRUE; + +static int window_close_callback(GLFWwindow window) +{ + running = GL_FALSE; + return GL_TRUE; +} + int main(void) { int width, height, x; @@ -36,6 +44,8 @@ int main(void) // Enable vertical sync (on cards that support it) glfwSwapInterval(1); + glfwSetWindowCloseCallback(window_close_callback); + do { double t = glfwGetTime(); @@ -82,9 +92,11 @@ int main(void) glfwSwapBuffers(); glfwPollEvents(); + if (glfwGetKey(window, GLFW_KEY_ESCAPE)) + running = GL_FALSE; + } // Check if the ESC key was pressed or the window was closed - while (glfwIsWindow(window) && - glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS); + while (running); // Close OpenGL window and terminate GLFW glfwTerminate(); diff --git a/examples/wave.c b/examples/wave.c index 54574839..00e74039 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -372,6 +372,17 @@ void window_resize_callback(GLFWwindow window, int width, int height) } +//======================================================================== +// Callback function for window close events +//======================================================================== + +static int window_close_callback(GLFWwindow window) +{ + running = GL_FALSE; + return GL_TRUE; +} + + //======================================================================== // main //======================================================================== @@ -401,6 +412,7 @@ int main(int argc, char* argv[]) glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE); // Window resize handler + glfwSetWindowCloseCallback(window_close_callback); glfwSetWindowSizeCallback(window_resize_callback); glfwSetMouseButtonCallback(mouse_button_callback); glfwSetCursorPosCallback(cursor_position_callback); @@ -441,9 +453,6 @@ int main(int argc, char* argv[]) draw_scene(); glfwPollEvents(); - - // Still running? - running = running && glfwIsWindow(window); } exit(EXIT_SUCCESS); diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 7a47f86e..f1d9f5cc 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -529,7 +529,6 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp); /* Window handling */ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share); GLFWAPI void glfwOpenWindowHint(int target, int hint); -GLFWAPI int glfwIsWindow(GLFWwindow window); GLFWAPI void glfwCloseWindow(GLFWwindow window); GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); diff --git a/readme.html b/readme.html index 12f73f3c..9627ecb6 100644 --- a/readme.html +++ b/readme.html @@ -268,7 +268,6 @@ version of GLFW.

v3.0

  • Added GLFWwindow window handle type and updated window-related functions and callbacks to take a window handle
  • -
  • Added glfwIsWindow function for verifying that a given window handle is (still) valid
  • Added glfwMakeContextCurrent function for making the context of the specified window current
  • Added glfwGetError and glfwErrorString error reporting functions and a number of error tokens
  • Added glfwSetErrorCallback function and GLFWerrorfun type for receiving more specific and/or nested errors
  • diff --git a/src/window.c b/src/window.c index 27237329..fb69396d 100644 --- a/src/window.c +++ b/src/window.c @@ -350,34 +350,6 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, } -//======================================================================== -// Returns GL_TRUE if the specified window handle is an actual window -//======================================================================== - -GLFWAPI int glfwIsWindow(GLFWwindow handle) -{ - _GLFWwindow* entry; - _GLFWwindow* window = (_GLFWwindow*) handle; - - if (!_glfwInitialized) - { - _glfwSetError(GLFW_NOT_INITIALIZED, NULL); - return GL_FALSE; - } - - if (window == NULL) - return GL_FALSE; - - for (entry = _glfwLibrary.windowListHead; entry; entry = entry->next) - { - if (entry == window) - return GL_TRUE; - } - - return GL_FALSE; -} - - //======================================================================== // Set hints for opening the window //======================================================================== diff --git a/tests/accuracy.c b/tests/accuracy.c index cfb70271..614f270f 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -79,7 +79,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/clipboard.c b/tests/clipboard.c index 3b732290..05724f25 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -136,7 +136,7 @@ int main(int argc, char** argv) glClearColor(0.5f, 0.5f, 0.5f, 0); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/events.c b/tests/events.c index 8ab54266..7528e96f 100644 --- a/tests/events.c +++ b/tests/events.c @@ -385,7 +385,7 @@ int main(void) printf("Main loop starting\n"); - while (glfwIsWindow(window) == GL_TRUE) + while (glfwGetCurrentContext()) glfwWaitEvents(); glfwTerminate(); diff --git a/tests/fsaa.c b/tests/fsaa.c index 9c45ddcc..4d22c4a6 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -127,7 +127,7 @@ int main(int argc, char** argv) gluOrtho2D(0.f, 1.f, 0.f, 0.5f); glMatrixMode(GL_MODELVIEW); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { GLfloat time = (GLfloat) glfwGetTime(); diff --git a/tests/fsfocus.c b/tests/fsfocus.c index 951409a6..b4bc7cb4 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -68,6 +68,7 @@ static void window_key_callback(GLFWwindow window, int key, int action) static int window_close_callback(GLFWwindow window) { printf("%0.3f: User closed window\n", glfwGetTime()); + running = GL_FALSE; return GL_TRUE; } @@ -97,7 +98,7 @@ int main(void) glfwSetKeyCallback(window_key_callback); glfwSetWindowCloseCallback(window_close_callback); - while (running && glfwIsWindow(window) == GL_TRUE) + while (running) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(); diff --git a/tests/gamma.c b/tests/gamma.c index b8ec6c45..22b6acd5 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -151,7 +151,7 @@ int main(int argc, char** argv) glClearColor(0.5f, 0.5f, 0.5f, 0); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/iconify.c b/tests/iconify.c index dbc4d9cf..f9333f47 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -126,7 +126,7 @@ int main(int argc, char** argv) glEnable(GL_SCISSOR_TEST); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { int width, height; diff --git a/tests/joysticks.c b/tests/joysticks.c index 2f208d2b..3abd5fdd 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -44,7 +44,6 @@ typedef struct Joystick } Joystick; static Joystick joysticks[GLFW_JOYSTICK_LAST - GLFW_JOYSTICK_1 + 1]; - static int joystick_count = 0; static void window_size_callback(GLFWwindow window, int width, int height) @@ -199,7 +198,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); - while (glfwIsWindow(window)) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/peter.c b/tests/peter.c index b9f21f22..e814caf6 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -127,7 +127,7 @@ int main(void) glClearColor(0.f, 0.f, 0.f, 0.f); - while (glfwIsWindow(window_handle)) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/sharing.c b/tests/sharing.c index 6f1df980..ed5ae024 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -36,12 +36,30 @@ #define WIDTH 400 #define HEIGHT 400 +static GLFWwindow windows[2]; + static void key_callback(GLFWwindow window, int key, int action) { if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) glfwCloseWindow(window); } +static int window_close_callback(GLFWwindow window) +{ + int i; + + for (i = 0; i < 2; i++) + { + if (windows[i] == window) + { + windows[i] = NULL; + break; + } + } + + return GL_TRUE; +} + static GLFWwindow open_window(const char* title, GLFWwindow share) { GLFWwindow window; @@ -50,6 +68,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) if (!window) return NULL; + glfwSetWindowCloseCallback(window_close_callback); glfwSetKeyCallback(key_callback); glfwSwapInterval(1); @@ -112,7 +131,6 @@ static void draw_quad(GLuint texture) int main(int argc, char** argv) { - GLFWwindow windows[2]; GLuint texture; int x, y; @@ -150,7 +168,7 @@ int main(int argc, char** argv) glfwGetWindowPos(windows[0], &x, &y); glfwSetWindowPos(windows[1], x + WIDTH + 50, y); - while (glfwIsWindow(windows[0]) && glfwIsWindow(windows[1])) + while (windows[0] && windows[1]) { glfwMakeContextCurrent(windows[0]); draw_quad(texture); diff --git a/tests/tearing.c b/tests/tearing.c index 1eab454e..64819c17 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -87,7 +87,7 @@ int main(void) glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); - while (glfwIsWindow(window) == GL_TRUE) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/title.c b/tests/title.c index 7b342d94..310713c4 100644 --- a/tests/title.c +++ b/tests/title.c @@ -58,7 +58,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); - while (glfwIsWindow(window) == GL_TRUE) + while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(); diff --git a/tests/windows.c b/tests/windows.c index c7ff32b2..601db132 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -32,6 +32,14 @@ #include #include +static GLboolean running = GL_TRUE; + +static int window_close_callback(GLFWwindow window) +{ + running = GL_FALSE; + return GL_TRUE; +} + static const char* titles[] = { "Foo", @@ -43,7 +51,6 @@ static const char* titles[] = int main(void) { int i; - GLboolean running = GL_TRUE; GLFWwindow windows[4]; if (!glfwInit()) @@ -53,6 +60,8 @@ int main(void) exit(EXIT_FAILURE); } + glfwSetWindowCloseCallback(window_close_callback); + for (i = 0; i < 4; i++) { windows[i] = glfwOpenWindow(200, 200, GLFW_WINDOWED, titles[i], NULL); @@ -82,12 +91,6 @@ int main(void) } glfwPollEvents(); - - for (i = 0; i < 4; i++) - { - if (!glfwIsWindow(windows[i])) - running = GL_FALSE; - } } glfwTerminate(); From 6b46225e33f098e84b981828b41c4c08ba46c35f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 3 Aug 2012 16:28:17 +0200 Subject: [PATCH 03/29] Declared all window close callbacks as static. --- examples/boing.c | 3 +-- examples/gears.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index d3b34172..6dbca066 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -43,7 +43,6 @@ void init( void ); void display( void ); void reshape( GLFWwindow window, int w, int h ); -int window_close_callback(GLFWwindow window); void DrawBoingBall( void ); void BounceBall( double dt ); void DrawBoingBallBand( GLfloat long_lo, GLfloat long_hi ); @@ -250,7 +249,7 @@ void reshape( GLFWwindow window, int w, int h ) /***************************************************************************** * Window close callback *****************************************************************************/ -int window_close_callback(GLFWwindow window) +static int window_close_callback(GLFWwindow window) { running = GL_FALSE; return GL_TRUE; diff --git a/examples/gears.c b/examples/gears.c index 4ce68ab6..9d9c7d60 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -268,7 +268,7 @@ void reshape( GLFWwindow window, int width, int height ) /* close callback */ -int window_close_callback(GLFWwindow window) +static int window_close_callback(GLFWwindow window) { running = 0; return GL_TRUE; From 13ff3eeca956a15666b70891b84225a04bfbce16 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 3 Aug 2012 19:54:07 +0200 Subject: [PATCH 04/29] Test program swap interval toggling work. --- tests/accuracy.c | 27 +++++++++++++++++++++++++-- tests/tearing.c | 15 +++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tests/accuracy.c b/tests/accuracy.c index 614f270f..4a3a2b04 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -37,6 +37,21 @@ static int cursor_x = 0, cursor_y = 0; static int window_width = 640, window_height = 480; +static int swap_interval = 1; + +static void set_swap_interval(GLFWwindow window, int interval) +{ + char title[256]; + + swap_interval = interval; + glfwSwapInterval(swap_interval); + + snprintf(title, sizeof(title), + "Cursor Inaccuracy Detector (interval %i)", + swap_interval); + + glfwSetWindowTitle(window, title); +} static void window_size_callback(GLFWwindow window, int width, int height) { @@ -56,6 +71,12 @@ static void cursor_position_callback(GLFWwindow window, int x, int y) cursor_y = y; } +static void key_callback(GLFWwindow window, int key, int action) +{ + if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) + set_swap_interval(window, 1 - swap_interval); +} + int main(void) { GLFWwindow window; @@ -66,7 +87,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "Cursor Inaccuracy Detector", NULL); + window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); if (!window) { glfwTerminate(); @@ -75,9 +96,11 @@ int main(void) exit(EXIT_FAILURE); } + set_swap_interval(window, swap_interval); + glfwSetCursorPosCallback(cursor_position_callback); glfwSetWindowSizeCallback(window_size_callback); - glfwSwapInterval(1); + glfwSetKeyCallback(key_callback); while (glfwGetCurrentContext()) { diff --git a/tests/tearing.c b/tests/tearing.c index 64819c17..de60f3c7 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -36,15 +36,18 @@ static int swap_interval; -static void set_swap_interval(int value) +static void set_swap_interval(GLFWwindow window, int interval) { char title[256]; - swap_interval = value; + swap_interval = interval; glfwSwapInterval(swap_interval); - sprintf(title, "Tearing detector (interval %i)", swap_interval); - glfwSetWindowTitle(glfwGetCurrentContext(), title); + snprintf(title, sizeof(title), + "Tearing detector (interval %i)", + swap_interval); + + glfwSetWindowTitle(window, title); } static void window_size_callback(GLFWwindow window, int width, int height) @@ -55,7 +58,7 @@ static void window_size_callback(GLFWwindow window, int width, int height) static void key_callback(GLFWwindow window, int key, int action) { if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) - set_swap_interval(!swap_interval); + set_swap_interval(window, 1 - swap_interval); } int main(void) @@ -78,7 +81,7 @@ int main(void) exit(EXIT_FAILURE); } - set_swap_interval(1); + set_swap_interval(window, swap_interval); glfwSetWindowSizeCallback(window_size_callback); glfwSetKeyCallback(key_callback); From aff30d0baa42af743c1ed956fa6e517f35e37a4d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 6 Aug 2012 17:56:41 +0200 Subject: [PATCH 05/29] Renamed window creation/destruction functions. Renamed glfwOpenWindow to glfwCreateWindow. Renamed glfwCloseWindow to glfwDestroyWindow. Renamed glfwOpenWindowHint to glfwWindowHint. --- examples/boing.c | 4 ++-- examples/gears.c | 4 ++-- examples/heightmap.c | 12 ++++++------ examples/particles.c | 2 +- examples/pong3d.c | 2 +- examples/splitview.c | 4 ++-- examples/triangle.c | 2 +- examples/wave.c | 2 +- include/GL/glfw3.h | 10 +++++----- readme.html | 4 ++-- src/cocoa_window.m | 8 ++++---- src/init.c | 2 +- src/internal.h | 8 ++++---- src/opengl.c | 28 ++++++++++++++-------------- src/win32_opengl.c | 2 +- src/win32_window.c | 12 ++++++------ src/window.c | 28 ++++++++++++++-------------- src/x11_window.c | 8 ++++---- tests/accuracy.c | 2 +- tests/clipboard.c | 4 ++-- tests/defaults.c | 4 ++-- tests/events.c | 2 +- tests/fsaa.c | 4 ++-- tests/fsfocus.c | 2 +- tests/gamma.c | 4 ++-- tests/glfwinfo.c | 14 +++++++------- tests/iconify.c | 4 ++-- tests/joysticks.c | 2 +- tests/modes.c | 16 ++++++++-------- tests/peter.c | 4 ++-- tests/reopen.c | 4 ++-- tests/sharing.c | 4 ++-- tests/tearing.c | 2 +- tests/title.c | 2 +- tests/windows.c | 2 +- 35 files changed, 109 insertions(+), 109 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 6dbca066..bd6d4d29 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -587,9 +587,9 @@ int main( void ) exit( EXIT_FAILURE ); } - glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwOpenWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL ); + window = glfwCreateWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/gears.c b/examples/gears.c index 9d9c7d60..6fecb646 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -337,9 +337,9 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } - glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + glfwWindowHint(GLFW_DEPTH_BITS, 16); - window = glfwOpenWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL ); + window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL ); if (!window) { fprintf( stderr, "Failed to open GLFW window\n" ); diff --git a/examples/heightmap.c b/examples/heightmap.c index e926581a..7b03a1b3 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -581,13 +581,13 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - glfwOpenWindowHint(GLFW_WINDOW_RESIZABLE, GL_FALSE); - glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); - glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); - glfwOpenWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); + glfwWindowHint(GLFW_WINDOW_RESIZABLE, GL_FALSE); + glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, 3); + glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, 2); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_FALSE); - window = glfwOpenWindow(800, 600, GLFW_WINDOWED, "GLFW OpenGL3 Heightmap demo", NULL); + window = glfwCreateWindow(800, 600, GLFW_WINDOWED, "GLFW OpenGL3 Heightmap demo", NULL); if (! window ) { fprintf(stderr, "ERROR: Unable to create the OpenGL context and associated window\n"); diff --git a/examples/particles.c b/examples/particles.c index 403a9997..c7904e11 100644 --- a/examples/particles.c +++ b/examples/particles.c @@ -1028,7 +1028,7 @@ int main( int argc, char **argv ) } // Open OpenGL fullscreen window - if( !glfwOpenWindow( WIDTH, HEIGHT, 0,0,0,0, 16,0, GLFW_FULLSCREEN ) ) + if( !glfwCreateWindow( WIDTH, HEIGHT, 0,0,0,0, 16,0, GLFW_FULLSCREEN ) ) { fprintf( stderr, "Failed to open GLFW window\n" ); glfwTerminate(); diff --git a/examples/pong3d.c b/examples/pong3d.c index 1d1afd1f..58c9ee20 100644 --- a/examples/pong3d.c +++ b/examples/pong3d.c @@ -810,7 +810,7 @@ int main( void ) } // Open OpenGL window - if( !glfwOpenWindow( WIDTH, HEIGHT, 0,0,0,0, 16,0, GLFW_FULLSCREEN ) ) + if( !glfwCreateWindow( WIDTH, HEIGHT, 0,0,0,0, 16,0, GLFW_FULLSCREEN ) ) { fprintf( stderr, "Failed to open GLFW window\n" ); glfwTerminate(); diff --git a/examples/splitview.c b/examples/splitview.c index d9595717..2ab3a82c 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -464,10 +464,10 @@ int main(void) exit(EXIT_FAILURE); } - glfwOpenWindowHint(GLFW_DEPTH_BITS, 16); + glfwWindowHint(GLFW_DEPTH_BITS, 16); // Open OpenGL window - window = glfwOpenWindow(500, 500, GLFW_WINDOWED, "Split view demo", NULL); + window = glfwCreateWindow(500, 500, GLFW_WINDOWED, "Split view demo", NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window\n"); diff --git a/examples/triangle.c b/examples/triangle.c index bf26a94e..212f5df3 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -31,7 +31,7 @@ int main(void) } // Open a window and create its OpenGL context - window = glfwOpenWindow(640, 480, GLFW_WINDOWED, "Spinning Triangle", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Spinning Triangle", NULL); if (!window) { fprintf(stderr, "Failed to open GLFW window\n"); diff --git a/examples/wave.c b/examples/wave.c index 00e74039..d58f1711 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -398,7 +398,7 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } - window = glfwOpenWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL); if (!window) { fprintf(stderr, "Could not open window\n"); diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index f1d9f5cc..49e2bdf3 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -381,7 +381,7 @@ extern "C" { * Other definitions *************************************************************************/ -/* glfwOpenWindow modes */ +/* glfwCreateWindow modes */ #define GLFW_WINDOWED 0x00010001 #define GLFW_FULLSCREEN 0x00010002 @@ -391,7 +391,7 @@ extern "C" { #define GLFW_OPENGL_REVISION 0x00020004 /* The following constants are used for both glfwGetWindowParam - * and glfwOpenWindowHint + * and glfwWindowHint */ #define GLFW_RED_BITS 0x00021000 #define GLFW_GREEN_BITS 0x00021001 @@ -527,9 +527,9 @@ GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp); GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp); /* Window handling */ -GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, int mode, const char* title, GLFWwindow share); -GLFWAPI void glfwOpenWindowHint(int target, int hint); -GLFWAPI void glfwCloseWindow(GLFWwindow window); +GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share); +GLFWAPI void glfwWindowHint(int target, int hint); +GLFWAPI void glfwDestroyWindow(GLFWwindow window); GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); GLFWAPI void glfwSetWindowSize(GLFWwindow, int width, int height); diff --git a/readme.html b/readme.html index 9627ecb6..c5447a20 100644 --- a/readme.html +++ b/readme.html @@ -287,20 +287,20 @@ version of GLFW.

  • Added sharing simple OpenGL object sharing test program
  • Added modes video mode enumeration and setting test program
  • Added glfw3native.h header and platform-specific functions for explicit access to native display, window and context handles
  • -
  • Added a parameter to glfwOpenWindow for specifying a context the new window's context will share objects with
  • -
  • Added initial window title parameter to glfwOpenWindow
  • Added glfwSetGamma, glfwSetGammaRamp and glfwGetGammaRamp functions and GLFWgammaramp type for monitor gamma ramp control
  • Changed buffer bit depth parameters of glfwOpenWindow to window hints
  • Changed glfwOpenWindow and glfwSetWindowTitle to use UTF-8 encoded strings
  • Changed glfwGetProcAddress to return a (generic) function pointer
  • 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_WINDOW_RESIZABLE
  • Renamed GLFW_BUILD_DLL to _GLFW_BUILD_DLL
  • Renamed version test to glfwinfo
  • Renamed GLFW_NO_GLU to GLFW_INCLUDE_GLU and made it disabled by default
  • Renamed mouse position functions to cursor position equivalents
  • +
  • Replaced glfwOpenWindow and glfwCloseWindow with glfwCreateWindow and glfwDestroyWindow
  • Replaced ad hoc build system with CMake
  • Replaced layout-dependent key codes with single, platform-independent set based on US layout
  • Replaced mouse wheel interface with two-dimensional, floating point scrolling interface
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 2f6b851c..0d8ec67d 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -860,9 +860,9 @@ static GLboolean createContext(_GLFWwindow* window, // created //======================================================================== -int _glfwPlatformOpenWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +int _glfwPlatformCreateWindow(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { if (!initializeAppKit()) return GL_FALSE; @@ -944,7 +944,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, // Properly kill the window / video display //======================================================================== -void _glfwPlatformCloseWindow(_GLFWwindow* window) +void _glfwPlatformDestroyWindow(_GLFWwindow* window) { [window->NS.object orderOut:nil]; diff --git a/src/init.c b/src/init.c index eab5869f..e1d5dfc9 100644 --- a/src/init.c +++ b/src/init.c @@ -79,7 +79,7 @@ GLFWAPI void glfwTerminate(void) // Close all remaining windows while (_glfwLibrary.windowListHead) - glfwCloseWindow(_glfwLibrary.windowListHead); + glfwDestroyWindow(_glfwLibrary.windowListHead); if (!_glfwPlatformTerminate()) return; diff --git a/src/internal.h b/src/internal.h index 81eb26c6..5d22e15e 100644 --- a/src/internal.h +++ b/src/internal.h @@ -88,10 +88,10 @@ typedef struct _GLFWlibrary _GLFWlibrary; //------------------------------------------------------------------------ -// Window hints, set by glfwOpenWindowHint and consumed by glfwOpenWindow +// Window hints, set by glfwWindowHint and consumed by glfwCreateWindow // A bucket of semi-random stuff lumped together for historical reasons // This is used only by the platform independent code and only to store -// parameters passed to us by glfwOpenWindowHint +// parameters passed to us by glfwWindowHint //------------------------------------------------------------------------ struct _GLFWhints { @@ -310,8 +310,8 @@ double _glfwPlatformGetTime(void); void _glfwPlatformSetTime(double time); // Window management -int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig); -void _glfwPlatformCloseWindow(_GLFWwindow* window); +int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig); +void _glfwPlatformDestroyWindow(_GLFWwindow* window); void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title); void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height); void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y); diff --git a/src/opengl.c b/src/opengl.c index 59166bfa..24889e07 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -244,7 +244,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, //======================================================================== // Checks whether the OpenGL part of the window config is sane -// It blames glfwOpenWindow because that's the only caller +// It blames glfwCreateWindow because that's the only caller //======================================================================== GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) @@ -253,28 +253,28 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) { // OpenGL 1.0 is the smallest valid version _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL version requested"); + "glfwCreateWindow: Invalid OpenGL version requested"); return GL_FALSE; } if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5) { // OpenGL 1.x series ended with version 1.5 _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL version requested"); + "glfwCreateWindow: Invalid OpenGL version requested"); return GL_FALSE; } else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1) { // OpenGL 2.x series ended with version 2.1 _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL version requested"); + "glfwCreateWindow: Invalid OpenGL version requested"); return GL_FALSE; } else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3) { // OpenGL 3.x series ended with version 3.3 _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL version requested"); + "glfwCreateWindow: Invalid OpenGL version requested"); return GL_FALSE; } else @@ -292,7 +292,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) // everything 2.x and let the driver report invalid 2.x versions _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL ES 2.x version requested"); + "glfwCreateWindow: Invalid OpenGL ES 2.x version requested"); return GL_FALSE; } } @@ -302,7 +302,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE) { _glfwSetError(GLFW_INVALID_ENUM, - "glfwOpenWindow: Invalid OpenGL profile requested"); + "glfwCreateWindow: Invalid OpenGL profile requested"); return GL_FALSE; } @@ -313,7 +313,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) // and above _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Context profiles only exist for " + "glfwCreateWindow: Context profiles only exist for " "OpenGL version 3.2 and above"); return GL_FALSE; } @@ -323,7 +323,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) { // Forward-compatible contexts are only defined for OpenGL version 3.0 and above _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Forward compatibility only exist for " + "glfwCreateWindow: Forward compatibility only exist for " "OpenGL version 3.0 and above"); return GL_FALSE; } @@ -334,7 +334,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET) { _glfwSetError(GLFW_INVALID_VALUE, - "glfwOpenWindow: Invalid OpenGL robustness mode requested"); + "glfwCreateWindow: Invalid OpenGL robustness mode requested"); return GL_FALSE; } } @@ -345,7 +345,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig) //======================================================================== // Reads back context properties -// It blames glfwOpenWindow because that's the only caller +// It blames glfwCreateWindow because that's the only caller //======================================================================== GLboolean _glfwRefreshContextParams(void) @@ -369,7 +369,7 @@ GLboolean _glfwRefreshContextParams(void) if (!window->GetStringi) { _glfwSetError(GLFW_PLATFORM_ERROR, - "glfwOpenWindow: Entry point retrieval is broken"); + "glfwCreateWindow: Entry point retrieval is broken"); return GL_FALSE; } } @@ -433,7 +433,7 @@ GLboolean _glfwRefreshContextParams(void) //======================================================================== // Checks whether the current context fulfils the specified requirements -// It blames glfwOpenWindow because that's the only caller +// It blames glfwCreateWindow because that's the only caller //======================================================================== GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig) @@ -452,7 +452,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig) // {GLX|WGL}_ARB_create_context extension and fail here _glfwSetError(GLFW_VERSION_UNAVAILABLE, - "glfwOpenWindow: The requested OpenGL version is not available"); + "glfwCreateWindow: The requested OpenGL version is not available"); return GL_FALSE; } diff --git a/src/win32_opengl.c b/src/win32_opengl.c index 11a45346..2d85369f 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -505,7 +505,7 @@ int _glfwCreateContext(_GLFWwindow* window, void _glfwDestroyContext(_GLFWwindow* window) { - // This is duplicated from glfwCloseWindow + // This is duplicated from glfwDestroyWindow // TODO: Stop duplicating code if (window == _glfwLibrary.currentWindow) glfwMakeContextCurrent(NULL); diff --git a/src/win32_window.c b/src/win32_window.c index aced1511..62a53c03 100755 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -886,7 +886,7 @@ static int createWindow(_GLFWwindow* window, if (!wideTitle) { _glfwSetError(GLFW_PLATFORM_ERROR, - "glfwOpenWindow: Failed to convert title to wide string"); + "glfwCreateWindow: Failed to convert title to wide string"); return GL_FALSE; } @@ -931,7 +931,7 @@ static void destroyWindow(_GLFWwindow* window) { _glfwDestroyContext(window); - // This is duplicated from glfwCloseWindow + // This is duplicated from glfwDestroyWindow // TODO: Stop duplicating code if (window == _glfwLibrary.activeWindow) _glfwLibrary.activeWindow = NULL; @@ -953,9 +953,9 @@ static void destroyWindow(_GLFWwindow* window) // created //======================================================================== -int _glfwPlatformOpenWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +int _glfwPlatformCreateWindow(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { GLboolean recreateContext = GL_FALSE; @@ -1083,7 +1083,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, // Properly kill the window / video display //======================================================================== -void _glfwPlatformCloseWindow(_GLFWwindow* window) +void _glfwPlatformDestroyWindow(_GLFWwindow* window) { destroyWindow(window); diff --git a/src/window.c b/src/window.c index fb69396d..8bc5fbeb 100644 --- a/src/window.c +++ b/src/window.c @@ -60,7 +60,7 @@ static void closeFlaggedWindows(void) if (window->closeRequested) { _GLFWwindow* next = window->next; - glfwCloseWindow(window); + glfwDestroyWindow(window); window = next; } else @@ -214,9 +214,9 @@ void _glfwInputWindowDamage(_GLFWwindow* window) // Create the GLFW window and its associated context //======================================================================== -GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, - int mode, const char* title, - GLFWwindow share) +GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, + int mode, const char* title, + GLFWwindow share) { _GLFWfbconfig fbconfig; _GLFWwndconfig wndconfig; @@ -269,7 +269,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) { _glfwSetError(GLFW_INVALID_ENUM, - "glfwOpenWindow: Invalid enum for 'mode' parameter"); + "glfwCreateWindow: Invalid enum for 'mode' parameter"); return GL_FALSE; } @@ -295,7 +295,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, if (!window) { _glfwSetError(GLFW_OUT_OF_MEMORY, - "glfwOpenWindow: Failed to allocate window structure"); + "glfwCreateWindow: Failed to allocate window structure"); return NULL; } @@ -312,9 +312,9 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, window->systemKeys = GL_TRUE; // Open the actual window and create its context - if (!_glfwPlatformOpenWindow(window, &wndconfig, &fbconfig)) + if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig)) { - glfwCloseWindow(window); + glfwDestroyWindow(window); return GL_FALSE; } @@ -325,14 +325,14 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, glfwMakeContextCurrent(window); if (!_glfwRefreshContextParams()) { - glfwCloseWindow(window); + glfwDestroyWindow(window); return GL_FALSE; } // Verify the context against the requested parameters if (!_glfwIsValidContext(&wndconfig)) { - glfwCloseWindow(window); + glfwDestroyWindow(window); return GL_FALSE; } @@ -351,10 +351,10 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height, //======================================================================== -// Set hints for opening the window +// Set hints for creating the window //======================================================================== -GLFWAPI void glfwOpenWindowHint(int target, int hint) +GLFWAPI void glfwWindowHint(int target, int hint) { if (!_glfwInitialized) { @@ -438,7 +438,7 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint) // Properly kill the window / video display //======================================================================== -GLFWAPI void glfwCloseWindow(GLFWwindow handle) +GLFWAPI void glfwDestroyWindow(GLFWwindow handle) { _GLFWwindow* window = (_GLFWwindow*) handle; @@ -460,7 +460,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle) if (window == _glfwLibrary.activeWindow) _glfwLibrary.activeWindow = NULL; - _glfwPlatformCloseWindow(window); + _glfwPlatformDestroyWindow(window); // Unlink window from global linked list { diff --git a/src/x11_window.c b/src/x11_window.c index 656c3735..cb0d5bcb 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -914,9 +914,9 @@ void _glfwProcessPendingEvents(void) // the OpenGL rendering context is created //======================================================================== -int _glfwPlatformOpenWindow(_GLFWwindow* window, - const _GLFWwndconfig* wndconfig, - const _GLFWfbconfig* fbconfig) +int _glfwPlatformCreateWindow(_GLFWwindow* window, + const _GLFWwndconfig* wndconfig, + const _GLFWfbconfig* fbconfig) { window->refreshRate = wndconfig->refreshRate; window->resizable = wndconfig->resizable; @@ -973,7 +973,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window, // Properly kill the window/video display //======================================================================== -void _glfwPlatformCloseWindow(_GLFWwindow* window) +void _glfwPlatformDestroyWindow(_GLFWwindow* window) { if (window->mode == GLFW_FULLSCREEN) leaveFullscreenMode(window); diff --git a/tests/accuracy.c b/tests/accuracy.c index 4a3a2b04..836bb18b 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -87,7 +87,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); + window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); if (!window) { glfwTerminate(); diff --git a/tests/clipboard.c b/tests/clipboard.c index 05724f25..58e9bdd7 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -53,7 +53,7 @@ static void key_callback(GLFWwindow window, int key, int action) switch (key) { case GLFW_KEY_ESCAPE: - glfwCloseWindow(window); + glfwDestroyWindow(window); break; case GLFW_KEY_V: @@ -117,7 +117,7 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Clipboard Test", NULL); if (!window) { glfwTerminate(); diff --git a/tests/defaults.c b/tests/defaults.c index 16c62723..289e2c60 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -74,7 +74,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Defaults", NULL); if (!window) { glfwTerminate(); @@ -94,7 +94,7 @@ int main(void) glfwGetWindowParam(window, parameters[i].param)); } - glfwCloseWindow(window); + glfwDestroyWindow(window); window = NULL; glfwTerminate(); diff --git a/tests/events.c b/tests/events.c index 7528e96f..85c6913f 100644 --- a/tests/events.c +++ b/tests/events.c @@ -367,7 +367,7 @@ int main(void) glfwSetKeyCallback(key_callback); glfwSetCharCallback(char_callback); - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Event Linter", NULL); if (!window) { glfwTerminate(); diff --git a/tests/fsaa.c b/tests/fsaa.c index 4d22c4a6..0b11ac75 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -96,9 +96,9 @@ int main(int argc, char** argv) glfwSetKeyCallback(key_callback); glfwSetWindowSizeCallback(window_size_callback); - glfwOpenWindowHint(GLFW_FSAA_SAMPLES, samples); + glfwWindowHint(GLFW_FSAA_SAMPLES, samples); - window = glfwOpenWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); + window = glfwCreateWindow(800, 400, GLFW_WINDOWED, "Aliasing Detector", NULL); if (!window) { glfwTerminate(); diff --git a/tests/fsfocus.c b/tests/fsfocus.c index b4bc7cb4..51075594 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -82,7 +82,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL); + window = glfwCreateWindow(640, 480, GLFW_FULLSCREEN, "Fullscreen focus", NULL); if (!window) { glfwTerminate(); diff --git a/tests/gamma.c b/tests/gamma.c index 22b6acd5..e9d487cd 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -60,7 +60,7 @@ static void key_callback(GLFWwindow window, int key, int action) { case GLFW_KEY_ESCAPE: { - glfwCloseWindow(window); + glfwDestroyWindow(window); break; } @@ -130,7 +130,7 @@ int main(int argc, char** argv) height = 0; } - window = glfwOpenWindow(width, height, mode, "Gamma Test", NULL); + window = glfwCreateWindow(width, height, mode, "Gamma Test", NULL); if (!window) { glfwTerminate(); diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index bbbedce0..4990ff09 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -191,26 +191,26 @@ int main(int argc, char** argv) if (major != 1 || minor != 0) { - glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, major); - glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, minor); + glfwWindowHint(GLFW_OPENGL_VERSION_MAJOR, major); + glfwWindowHint(GLFW_OPENGL_VERSION_MINOR, minor); } if (debug) - glfwOpenWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE); if (forward) - glfwOpenWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); if (profile != 0) - glfwOpenWindowHint(GLFW_OPENGL_PROFILE, profile); + glfwWindowHint(GLFW_OPENGL_PROFILE, profile); if (strategy) - glfwOpenWindowHint(GLFW_OPENGL_ROBUSTNESS, strategy); + glfwWindowHint(GLFW_OPENGL_ROBUSTNESS, strategy); // We assume here that we stand a better chance of success by leaving all // possible details of pixel format selection to GLFW - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Version", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL); if (!window) exit(EXIT_FAILURE); diff --git a/tests/iconify.c b/tests/iconify.c index f9333f47..4deb45e7 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -55,7 +55,7 @@ static void key_callback(GLFWwindow window, int key, int action) glfwIconifyWindow(window); break; case GLFW_KEY_ESCAPE: - glfwCloseWindow(window); + glfwDestroyWindow(window); break; } } @@ -111,7 +111,7 @@ int main(int argc, char** argv) height = 0; } - window = glfwOpenWindow(width, height, mode, "Iconify", NULL); + window = glfwCreateWindow(width, height, mode, "Iconify", NULL); if (!window) { glfwTerminate(); diff --git a/tests/joysticks.c b/tests/joysticks.c index 3abd5fdd..b2375b83 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -186,7 +186,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Joystick Test", NULL); if (!window) { glfwTerminate(); diff --git a/tests/modes.c b/tests/modes.c index 6d262ef3..9e72562a 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -85,7 +85,7 @@ static void key_callback(GLFWwindow dummy, int key, int action) { if (key == GLFW_KEY_ESCAPE) { - glfwCloseWindow(window); + glfwDestroyWindow(window); window = NULL; } } @@ -125,15 +125,15 @@ static void test_modes(void) { GLFWvidmode* mode = modes + i; - glfwOpenWindowHint(GLFW_RED_BITS, mode->redBits); - glfwOpenWindowHint(GLFW_GREEN_BITS, mode->greenBits); - glfwOpenWindowHint(GLFW_BLUE_BITS, mode->blueBits); + glfwWindowHint(GLFW_RED_BITS, mode->redBits); + glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); + glfwWindowHint(GLFW_BLUE_BITS, mode->blueBits); printf("Testing mode %u: %s", (unsigned int) i, format_mode(mode)); - window = glfwOpenWindow(mode->width, mode->height, - GLFW_FULLSCREEN, "Video Mode Test", - NULL); + window = glfwCreateWindow(mode->width, mode->height, + GLFW_FULLSCREEN, "Video Mode Test", + NULL); if (!window) { printf("Failed to enter mode %u: %s\n", @@ -182,7 +182,7 @@ static void test_modes(void) printf("Closing window\n"); - glfwCloseWindow(window); + glfwDestroyWindow(window); glfwPollEvents(); window = NULL; } diff --git a/tests/peter.c b/tests/peter.c index e814caf6..e79e5805 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -78,7 +78,7 @@ static void key_callback(GLFWwindow window, int key, int action) { if (action == GLFW_PRESS) { - glfwCloseWindow(window); + glfwDestroyWindow(window); open_window(); } @@ -94,7 +94,7 @@ static void window_size_callback(GLFWwindow window, int width, int height) static GLboolean open_window(void) { - window_handle = glfwOpenWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL); + window_handle = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Peter Detector", NULL); if (!window_handle) return GL_FALSE; diff --git a/tests/reopen.c b/tests/reopen.c index 2922cb84..1d692b80 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -92,7 +92,7 @@ static GLboolean open_window(int width, int height, int mode) base = glfwGetTime(); - window_handle = glfwOpenWindow(width, height, mode, "Window Re-opener", NULL); + window_handle = glfwCreateWindow(width, height, mode, "Window Re-opener", NULL); if (!window_handle) { fprintf(stderr, "Failed to open %s mode GLFW window: %s\n", get_mode_name(mode), glfwErrorString(glfwGetError())); @@ -115,7 +115,7 @@ static void close_window(void) { double base = glfwGetTime(); - glfwCloseWindow(window_handle); + glfwDestroyWindow(window_handle); window_handle = NULL; printf("Closing window took %0.3f seconds\n", glfwGetTime() - base); diff --git a/tests/sharing.c b/tests/sharing.c index ed5ae024..5a2e028f 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -41,7 +41,7 @@ static GLFWwindow windows[2]; static void key_callback(GLFWwindow window, int key, int action) { if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE) - glfwCloseWindow(window); + glfwDestroyWindow(window); } static int window_close_callback(GLFWwindow window) @@ -64,7 +64,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) { GLFWwindow window; - window = glfwOpenWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share); + window = glfwCreateWindow(WIDTH, HEIGHT, GLFW_WINDOWED, title, share); if (!window) return NULL; diff --git a/tests/tearing.c b/tests/tearing.c index de60f3c7..3ab131cd 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -72,7 +72,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL); if (!window) { glfwTerminate(); diff --git a/tests/title.c b/tests/title.c index 310713c4..a66160b8 100644 --- a/tests/title.c +++ b/tests/title.c @@ -47,7 +47,7 @@ int main(void) exit(EXIT_FAILURE); } - window = glfwOpenWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", NULL); + window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "English 日本語 русский язык 官話", 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 601db132..ac7500ad 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -64,7 +64,7 @@ int main(void) for (i = 0; i < 4; i++) { - windows[i] = glfwOpenWindow(200, 200, GLFW_WINDOWED, titles[i], NULL); + windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL); if (!windows[i]) { fprintf(stderr, "Failed to open GLFW window: %s\n", From 585a840329ecc803ef363949b1e5eb28624c4a49 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Mon, 6 Aug 2012 18:13:37 +0200 Subject: [PATCH 06/29] Added window parameter to glfwSwapBuffers. --- examples/boing.c | 2 +- examples/gears.c | 2 +- examples/heightmap.c | 2 +- examples/splitview.c | 2 +- examples/triangle.c | 2 +- examples/wave.c | 6 +++--- include/GL/glfw3.h | 2 +- readme.html | 1 + src/cocoa_opengl.m | 4 +--- src/internal.h | 2 +- src/opengl.c | 12 ++++-------- src/win32_opengl.c | 4 +--- src/window.c | 2 +- src/x11_opengl.c | 5 ++--- tests/accuracy.c | 2 +- tests/clipboard.c | 2 +- tests/events.c | 2 +- tests/fsaa.c | 2 +- tests/fsfocus.c | 2 +- tests/gamma.c | 2 +- tests/iconify.c | 2 +- tests/joysticks.c | 2 +- tests/modes.c | 2 +- tests/peter.c | 2 +- tests/reopen.c | 2 +- tests/sharing.c | 5 +++-- tests/tearing.c | 2 +- tests/title.c | 2 +- tests/windows.c | 2 +- 29 files changed, 37 insertions(+), 44 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index bd6d4d29..9b7e2022 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -617,7 +617,7 @@ int main( void ) display(); /* Swap buffers */ - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); /* Check if we are still running */ diff --git a/examples/gears.c b/examples/gears.c index 6fecb646..535a574d 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -368,7 +368,7 @@ int main(int argc, char *argv[]) animate(); // Swap buffers - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/examples/heightmap.c b/examples/heightmap.c index 7b03a1b3..ce894f99 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -663,7 +663,7 @@ int main(int argc, char** argv) glDrawElements(GL_LINES, 2* MAP_NUM_LINES , GL_UNSIGNED_INT, 0); /* display and process events through callbacks */ - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); /* Check the frame rate and update the heightmap if needed */ dt = glfwGetTime(); diff --git a/examples/splitview.c b/examples/splitview.c index 2ab3a82c..0b767b7f 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -500,7 +500,7 @@ int main(void) drawAllViews(); // Swap buffers - glfwSwapBuffers(); + glfwSwapBuffers(window); do_redraw = 0; } diff --git a/examples/triangle.c b/examples/triangle.c index 212f5df3..8a352ca9 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -89,7 +89,7 @@ int main(void) glEnd(); // Swap buffers - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); if (glfwGetKey(window, GLFW_KEY_ESCAPE)) diff --git a/examples/wave.c b/examples/wave.c index d58f1711..ae5447f8 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -145,7 +145,7 @@ void init_grid(void) // Draw scene //======================================================================== -void draw_scene(void) +void draw_scene(GLFWwindow window) { // Clear the color and depth buffers glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -162,7 +162,7 @@ void draw_scene(void) glDrawElements(GL_QUADS, 4 * QUADNUM, GL_UNSIGNED_INT, quad); - glfwSwapBuffers(); + glfwSwapBuffers(window); } @@ -450,7 +450,7 @@ int main(int argc, char* argv[]) adjust_grid(); // Draw wave grid to OpenGL display - draw_scene(); + draw_scene(window); glfwPollEvents(); } diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 49e2bdf3..718391cb 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -581,7 +581,7 @@ GLFWAPI void glfwSetTime(double time); /* OpenGL support */ GLFWAPI void glfwMakeContextCurrent(GLFWwindow window); GLFWAPI GLFWwindow glfwGetCurrentContext(void); -GLFWAPI void glfwSwapBuffers(void); +GLFWAPI void glfwSwapBuffers(GLFWwindow window); GLFWAPI void glfwSwapInterval(int interval); GLFWAPI int glfwExtensionSupported(const char* extension); GLFWAPI GLFWglproc glfwGetProcAddress(const char* procname); diff --git a/readme.html b/readme.html index c5447a20..8bf5d046 100644 --- a/readme.html +++ b/readme.html @@ -288,6 +288,7 @@ version of GLFW.

  • Added modes video mode enumeration and setting test program
  • Added glfw3native.h header and platform-specific functions for explicit access to native display, window and context handles
  • Added glfwSetGamma, glfwSetGammaRamp and glfwGetGammaRamp functions and GLFWgammaramp type for monitor gamma ramp control
  • +
  • Added window parameter to glfwSwapBuffers
  • Changed buffer bit depth parameters of glfwOpenWindow to window hints
  • Changed glfwOpenWindow and glfwSetWindowTitle to use UTF-8 encoded strings
  • Changed glfwGetProcAddress to return a (generic) function pointer
  • diff --git a/src/cocoa_opengl.m b/src/cocoa_opengl.m index b04efaee..2ffd774c 100644 --- a/src/cocoa_opengl.m +++ b/src/cocoa_opengl.m @@ -51,10 +51,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) // Swap buffers //======================================================================== -void _glfwPlatformSwapBuffers(void) +void _glfwPlatformSwapBuffers(_GLFWwindow* window) { - _GLFWwindow* window = _glfwLibrary.currentWindow; - // ARP appears to be unnecessary, but this is future-proof [window->NSGL.context flushBuffer]; } diff --git a/src/internal.h b/src/internal.h index 5d22e15e..1e4825c0 100644 --- a/src/internal.h +++ b/src/internal.h @@ -324,7 +324,7 @@ void _glfwPlatformWaitEvents(void); // OpenGL context management void _glfwPlatformMakeContextCurrent(_GLFWwindow* window); -void _glfwPlatformSwapBuffers(void); +void _glfwPlatformSwapBuffers(_GLFWwindow* window); void _glfwPlatformSwapInterval(int interval); void _glfwPlatformRefreshWindowParams(_GLFWwindow* window); int _glfwPlatformExtensionSupported(const char* extension); diff --git a/src/opengl.c b/src/opengl.c index 24889e07..19c07253 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -541,21 +541,17 @@ GLFWAPI GLFWwindow glfwGetCurrentContext(void) // Swap buffers (double-buffering) //======================================================================== -GLFWAPI void glfwSwapBuffers(void) +GLFWAPI void glfwSwapBuffers(GLFWwindow handle) { + _GLFWwindow* window = (_GLFWwindow*) handle; + if (!_glfwInitialized) { _glfwSetError(GLFW_NOT_INITIALIZED, NULL); return; } - if (!_glfwLibrary.currentWindow) - { - _glfwSetError(GLFW_NO_CURRENT_CONTEXT, NULL); - return; - } - - _glfwPlatformSwapBuffers(); + _glfwPlatformSwapBuffers(window); } diff --git a/src/win32_opengl.c b/src/win32_opengl.c index 2d85369f..fe1898e7 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -545,10 +545,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) // Swap buffers (double-buffering) //======================================================================== -void _glfwPlatformSwapBuffers(void) +void _glfwPlatformSwapBuffers(_GLFWwindow* window) { - _GLFWwindow* window = _glfwLibrary.currentWindow; - SwapBuffers(window->WGL.DC); } diff --git a/src/window.c b/src/window.c index 8bc5fbeb..3b0e7a55 100644 --- a/src/window.c +++ b/src/window.c @@ -344,7 +344,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, // Clearing the front buffer to black to avoid garbage pixels left over // from previous uses of our bit of VRAM glClear(GL_COLOR_BUFFER_BIT); - _glfwPlatformSwapBuffers(); + _glfwPlatformSwapBuffers(window); return window; } diff --git a/src/x11_opengl.c b/src/x11_opengl.c index 3549e573..2a5cc451 100644 --- a/src/x11_opengl.c +++ b/src/x11_opengl.c @@ -642,10 +642,9 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window) // Swap OpenGL buffers //======================================================================== -void _glfwPlatformSwapBuffers(void) +void _glfwPlatformSwapBuffers(_GLFWwindow* window) { - glXSwapBuffers(_glfwLibrary.X11.display, - _glfwLibrary.currentWindow->X11.handle); + glXSwapBuffers(_glfwLibrary.X11.display, window->X11.handle); } diff --git a/tests/accuracy.c b/tests/accuracy.c index 836bb18b..40894742 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -113,7 +113,7 @@ int main(void) glVertex2f((GLfloat) cursor_x, (GLfloat) window_height); glEnd(); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/clipboard.c b/tests/clipboard.c index 58e9bdd7..8ab90dbb 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -143,7 +143,7 @@ int main(int argc, char** argv) glColor3f(0.8f, 0.2f, 0.4f); glRectf(-0.5f, -0.5f, 0.5f, 0.5f); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwWaitEvents(); } diff --git a/tests/events.c b/tests/events.c index 85c6913f..0d345765 100644 --- a/tests/events.c +++ b/tests/events.c @@ -239,7 +239,7 @@ static void window_refresh_callback(GLFWwindow window) printf("%08x at %0.3f: Window refresh\n", counter++, glfwGetTime()); glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window); } static void window_focus_callback(GLFWwindow window, int activated) diff --git a/tests/fsaa.c b/tests/fsaa.c index 0b11ac75..e2e0623c 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -147,7 +147,7 @@ int main(int argc, char** argv) glEnable(GL_MULTISAMPLE_ARB); glRectf(-0.15f, -0.15f, 0.15f, 0.15f); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/fsfocus.c b/tests/fsfocus.c index 51075594..e718a319 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -101,7 +101,7 @@ int main(void) while (running) { glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwWaitEvents(); } diff --git a/tests/gamma.c b/tests/gamma.c index e9d487cd..1f3ca5e1 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -158,7 +158,7 @@ int main(int argc, char** argv) glColor3f(0.8f, 0.2f, 0.4f); glRectf(-0.5f, -0.5f, 0.5f, 0.5f); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/iconify.c b/tests/iconify.c index 4deb45e7..4f1c7d22 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -152,7 +152,7 @@ int main(int argc, char** argv) glClearColor(1, 1, 1, 0); glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/joysticks.c b/tests/joysticks.c index b2375b83..36952038 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -205,7 +205,7 @@ int main(void) refresh_joysticks(); draw_joysticks(); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/modes.c b/tests/modes.c index 9e72562a..eeb83abf 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -148,7 +148,7 @@ static void test_modes(void) while (glfwGetTime() < 5.0) { glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); if (!window) diff --git a/tests/peter.c b/tests/peter.c index e79e5805..7e0be921 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -131,7 +131,7 @@ int main(void) { glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window_handle); glfwWaitEvents(); } diff --git a/tests/reopen.c b/tests/reopen.c index 1d692b80..545ba280 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -147,7 +147,7 @@ int main(int argc, char** argv) glRectf(-0.5f, -0.5f, 1.f, 1.f); glPopMatrix(); - glfwSwapBuffers(); + glfwSwapBuffers(window_handle); glfwPollEvents(); if (closed) diff --git a/tests/sharing.c b/tests/sharing.c index 5a2e028f..8031a9bb 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -172,11 +172,12 @@ int main(int argc, char** argv) { glfwMakeContextCurrent(windows[0]); draw_quad(texture); - glfwSwapBuffers(); glfwMakeContextCurrent(windows[1]); draw_quad(texture); - glfwSwapBuffers(); + + glfwSwapBuffers(windows[0]); + glfwSwapBuffers(windows[1]); glfwWaitEvents(); } diff --git a/tests/tearing.c b/tests/tearing.c index 3ab131cd..19ffe531 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -97,7 +97,7 @@ int main(void) position = cosf(glfwGetTime() * 4.f) * 0.75f; glRectf(position - 0.25f, -1.f, position + 0.25f, 1.f); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/tests/title.c b/tests/title.c index a66160b8..918d7eed 100644 --- a/tests/title.c +++ b/tests/title.c @@ -61,7 +61,7 @@ int main(void) while (glfwGetCurrentContext()) { glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(window); glfwWaitEvents(); } diff --git a/tests/windows.c b/tests/windows.c index ac7500ad..27c1bd30 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -87,7 +87,7 @@ int main(void) { glfwMakeContextCurrent(windows[i]); glClear(GL_COLOR_BUFFER_BIT); - glfwSwapBuffers(); + glfwSwapBuffers(windows[i]); } glfwPollEvents(); From 99031a43a208b4606977edcf0095725a6027b72f Mon Sep 17 00:00:00 2001 From: Riku Salminen Date: Mon, 6 Aug 2012 21:24:53 +0300 Subject: [PATCH 07/29] X11: remove _glfwProcessPendingEvents Remove _glfwProcessPendingEvents, do not call event handlers from glfwCreateWindow. It is dangerous. Do not wait for MapNotify event in glfwCreateWindow under X11. --- src/x11_window.c | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/src/x11_window.c b/src/x11_window.c index cb0d5bcb..e90790f7 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -43,16 +43,6 @@ #define Button6 6 #define Button7 7 -//======================================================================== -// Checks whether the event is a MapNotify for the specified window -//======================================================================== - -static Bool isMapNotify(Display* d, XEvent* e, char* arg) -{ - return (e->type == MapNotify) && (e->xmap.window == (Window)arg); -} - - //======================================================================== // Translates an X Window key to internal coding //======================================================================== @@ -94,7 +84,6 @@ static int translateChar(XKeyEvent* event) static GLboolean createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig) { - XEvent event; unsigned long wamask; XSetWindowAttributes wa; XVisualInfo* visual = _glfwGetContextVisual(window); @@ -243,8 +232,7 @@ static GLboolean createWindow(_GLFWwindow* window, // Make sure the window is mapped before proceeding XMapWindow(_glfwLibrary.X11.display, window->X11.handle); - XPeekIfEvent(_glfwLibrary.X11.display, &event, isMapNotify, - (char*) window->X11.handle); + XFlush(_glfwLibrary.X11.display); return GL_TRUE; } @@ -887,24 +875,6 @@ static void processSingleEvent(void) } } - -////////////////////////////////////////////////////////////////////////// -////// GLFW internal API ////// -////////////////////////////////////////////////////////////////////////// - -//======================================================================== -// Processes all pending events -//======================================================================== - -void _glfwProcessPendingEvents(void) -{ - int i, count = XPending(_glfwLibrary.X11.display); - - for (i = 0; i < count; i++) - processSingleEvent(); -} - - ////////////////////////////////////////////////////////////////////////// ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// @@ -942,9 +912,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, enterFullscreenMode(window); } - // Process the window map event and any other that may have arrived - _glfwProcessPendingEvents(); - // Retrieve and set initial cursor position { Window cursorWindow, cursorRoot; From 8ed66ea4d58abddb19a9d27bbebf3a1b867568b0 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 7 Aug 2012 12:14:58 +0200 Subject: [PATCH 08/29] Removed calling of callbacks from setters. --- examples/boing.c | 9 +++++++-- examples/gears.c | 14 +++++++++----- examples/splitview.c | 18 +++++++++++------- examples/wave.c | 22 ++++++++++++---------- src/input.c | 10 ---------- src/window.c | 10 ---------- tests/accuracy.c | 12 ++++++++---- 7 files changed, 47 insertions(+), 48 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 9b7e2022..8348df66 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -579,6 +579,7 @@ void DrawGrid( void ) int main( void ) { GLFWwindow window; + int width, height; /* Init GLFW */ if( !glfwInit() ) @@ -587,6 +588,9 @@ int main( void ) exit( EXIT_FAILURE ); } + glfwSetWindowCloseCallback( window_close_callback ); + glfwSetWindowSizeCallback( reshape ); + glfwWindowHint(GLFW_DEPTH_BITS, 16); window = glfwCreateWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL ); @@ -597,8 +601,9 @@ int main( void ) exit( EXIT_FAILURE ); } - glfwSetWindowCloseCallback( window_close_callback ); - glfwSetWindowSizeCallback( reshape ); + glfwGetWindowSize(window, &width, &height); + reshape(window, width, height); + glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE ); glfwSwapInterval( 1 ); glfwSetTime( 0.0 ); diff --git a/examples/gears.c b/examples/gears.c index 535a574d..ccc06867 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -330,6 +330,7 @@ static void init(int argc, char *argv[]) int main(int argc, char *argv[]) { GLFWwindow window; + int width, height; if( !glfwInit() ) { @@ -337,6 +338,11 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } + // Set callback functions + glfwSetWindowCloseCallback(window_close_callback); + glfwSetWindowSizeCallback( reshape ); + glfwSetKeyCallback( key ); + glfwWindowHint(GLFW_DEPTH_BITS, 16); window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL ); @@ -347,17 +353,15 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } + glfwGetWindowSize(window, &width, &height); + reshape(window, width, height); + glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE ); glfwSwapInterval( 1 ); // Parse command-line options init(argc, argv); - // Set callback functions - glfwSetWindowCloseCallback(window_close_callback); - glfwSetWindowSizeCallback( reshape ); - glfwSetKeyCallback( key ); - // Main loop while( running ) { diff --git a/examples/splitview.c b/examples/splitview.c index 0b767b7f..e3f01806 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -456,6 +456,7 @@ static int windowCloseFun(GLFWwindow window) int main(void) { GLFWwindow window; + int width, height; // Initialise GLFW if (!glfwInit()) @@ -464,6 +465,13 @@ int main(void) exit(EXIT_FAILURE); } + // Set callback functions + glfwSetWindowCloseCallback(windowCloseFun); + glfwSetWindowSizeCallback(windowSizeFun); + glfwSetWindowRefreshCallback(windowRefreshFun); + glfwSetCursorPosCallback(cursorPosFun); + glfwSetMouseButtonCallback(mouseButtonFun); + glfwWindowHint(GLFW_DEPTH_BITS, 16); // Open OpenGL window @@ -474,6 +482,9 @@ int main(void) exit(EXIT_FAILURE); } + glfwGetWindowSize(window, &width, &height); + windowSizeFun(window, width, height); + // Enable vsync glfwSwapInterval(1); @@ -483,13 +494,6 @@ int main(void) // Enable mouse cursor (only needed for fullscreen mode) glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); - // Set callback functions - glfwSetWindowCloseCallback(windowCloseFun); - glfwSetWindowSizeCallback(windowSizeFun); - glfwSetWindowRefreshCallback(windowRefreshFun); - glfwSetCursorPosCallback(cursorPosFun); - glfwSetMouseButtonCallback(mouseButtonFun); - // Main loop do { diff --git a/examples/wave.c b/examples/wave.c index ae5447f8..e0c687d6 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -355,7 +355,7 @@ void scroll_callback(GLFWwindow window, double x, double y) // Callback function for window resize events //======================================================================== -void window_resize_callback(GLFWwindow window, int width, int height) +void window_size_callback(GLFWwindow window, int width, int height) { float ratio = 1.f; @@ -391,6 +391,7 @@ int main(int argc, char* argv[]) { GLFWwindow window; double t, dt_total, t_old; + int width, height; if (!glfwInit()) { @@ -398,6 +399,13 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } + glfwSetKeyCallback(key_callback); + glfwSetWindowCloseCallback(window_close_callback); + glfwSetWindowSizeCallback(window_size_callback); + glfwSetMouseButtonCallback(mouse_button_callback); + glfwSetCursorPosCallback(cursor_position_callback); + glfwSetScrollCallback(scroll_callback); + window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL); if (!window) { @@ -405,19 +413,13 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } + glfwGetWindowSize(window, &width, &height); + window_size_callback(window, width, height); + glfwSwapInterval(1); - // Keyboard handler - glfwSetKeyCallback(key_callback); glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE); - // Window resize handler - glfwSetWindowCloseCallback(window_close_callback); - glfwSetWindowSizeCallback(window_resize_callback); - glfwSetMouseButtonCallback(mouse_button_callback); - glfwSetCursorPosCallback(cursor_position_callback); - glfwSetScrollCallback(scroll_callback); - // Initialize OpenGL init_opengl(); diff --git a/src/input.c b/src/input.c index 37da571a..52b3b0fb 100644 --- a/src/input.c +++ b/src/input.c @@ -551,16 +551,6 @@ GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun) } _glfwLibrary.cursorPosCallback = cbfun; - - // Call the callback function to let the application know the current - // cursor position - if (cbfun) - { - _GLFWwindow* window; - - for (window = _glfwLibrary.windowListHead; window; window = window->next) - cbfun(window, window->cursorPosX, window->cursorPosY); - } } diff --git a/src/window.c b/src/window.c index 3b0e7a55..f281a256 100644 --- a/src/window.c +++ b/src/window.c @@ -762,16 +762,6 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun) } _glfwLibrary.windowSizeCallback = cbfun; - - // Call the callback function to let the application know the current - // window size - if (cbfun) - { - _GLFWwindow* window; - - for (window = _glfwLibrary.windowListHead; window; window = window->next) - cbfun(window, window->width, window->height); - } } diff --git a/tests/accuracy.c b/tests/accuracy.c index 40894742..079a88b8 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -80,6 +80,7 @@ static void key_callback(GLFWwindow window, int key, int action) int main(void) { GLFWwindow window; + int width, height; if (!glfwInit()) { @@ -87,6 +88,10 @@ int main(void) exit(EXIT_FAILURE); } + glfwSetCursorPosCallback(cursor_position_callback); + glfwSetWindowSizeCallback(window_size_callback); + glfwSetKeyCallback(key_callback); + window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); if (!window) { @@ -96,11 +101,10 @@ int main(void) exit(EXIT_FAILURE); } - set_swap_interval(window, swap_interval); + glfwGetWindowSize(window, &width, &height); + window_size_callback(window, width, height); - glfwSetCursorPosCallback(cursor_position_callback); - glfwSetWindowSizeCallback(window_size_callback); - glfwSetKeyCallback(key_callback); + set_swap_interval(window, swap_interval); while (glfwGetCurrentContext()) { From d4e1f98394c90e8c397d16f7a612403afbb35feb Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 7 Aug 2012 13:01:19 +0200 Subject: [PATCH 09/29] Added output of initial window size. --- tests/events.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/events.c b/tests/events.c index 0d345765..e9b7b7d2 100644 --- a/tests/events.c +++ b/tests/events.c @@ -344,6 +344,7 @@ static void char_callback(GLFWwindow window, int character) int main(void) { GLFWwindow window; + int width, height; setlocale(LC_ALL, ""); @@ -380,6 +381,9 @@ int main(void) glfwSwapInterval(1); + glfwGetWindowSize(window, &width, &height); + printf("Window size should be %ix%i\n", width, height); + printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled"); printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled"); From f71daaa14b1d585fca59afb4228d2554aab48b05 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 7 Aug 2012 13:09:31 +0200 Subject: [PATCH 10/29] Removed executable flag from source file. --- src/win32_window.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 src/win32_window.c diff --git a/src/win32_window.c b/src/win32_window.c old mode 100755 new mode 100644 From 3216661da7d93f1cc4e4f7410c3c9a608379e846 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 7 Aug 2012 21:40:40 +0200 Subject: [PATCH 11/29] Removed ill-advised use of glfwGetCurrentContext. --- tests/events.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/events.c b/tests/events.c index e9b7b7d2..bd8b1546 100644 --- a/tests/events.c +++ b/tests/events.c @@ -40,11 +40,17 @@ #include #include +// These must match the input mode defaults static GLboolean keyrepeat = GL_FALSE; static GLboolean systemkeys = GL_TRUE; static GLboolean closeable = GL_TRUE; + +// Event index static unsigned int counter = 0; +// Should we keep running? +static GLboolean running = GL_TRUE; + static const char* get_key_name(int key) { switch (key) @@ -231,6 +237,10 @@ static void window_size_callback(GLFWwindow window, int width, int height) static int window_close_callback(GLFWwindow window) { printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime()); + + if (closeable) + running = GL_FALSE; + return closeable; } @@ -389,7 +399,7 @@ int main(void) printf("Main loop starting\n"); - while (glfwGetCurrentContext()) + while (running) glfwWaitEvents(); glfwTerminate(); From ddcf5d471e4a089ff0bf4723f1660fbcdaead6f3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 10 Aug 2012 13:03:11 +0200 Subject: [PATCH 12/29] Removed mirroring of default framebuffer attribs. --- include/GL/glfw3.h | 8 +++--- readme.html | 1 + src/internal.h | 15 ----------- src/opengl.c | 21 ---------------- src/window.c | 26 ------------------- tests/defaults.c | 63 +++++++++++++++++++++++++++++++++------------- tests/fsaa.c | 2 +- tests/modes.c | 29 ++++++++++----------- 8 files changed, 67 insertions(+), 98 deletions(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 718391cb..45dd1aad 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -390,9 +390,7 @@ extern "C" { #define GLFW_ICONIFIED 0x00020002 #define GLFW_OPENGL_REVISION 0x00020004 -/* The following constants are used for both glfwGetWindowParam - * and glfwWindowHint - */ +/* glfwWindowHint tokens */ #define GLFW_RED_BITS 0x00021000 #define GLFW_GREEN_BITS 0x00021001 #define GLFW_BLUE_BITS 0x00021002 @@ -408,6 +406,10 @@ extern "C" { #define GLFW_STEREO 0x0002100C #define GLFW_WINDOW_RESIZABLE 0x0002100D #define GLFW_FSAA_SAMPLES 0x0002100E + +/* The following constants are used with both glfwGetWindowParam + * and glfwWindowHint + */ #define GLFW_OPENGL_VERSION_MAJOR 0x0002100F #define GLFW_OPENGL_VERSION_MINOR 0x00021010 #define GLFW_OPENGL_FORWARD_COMPAT 0x00021011 diff --git a/readme.html b/readme.html index 8bf5d046..b93b7c6b 100644 --- a/readme.html +++ b/readme.html @@ -320,6 +320,7 @@ version of GLFW.

  • Removed nonsensical key actions for Unicode character input
  • Removed GLFWCALL and GLFWAPIENTRY macros for stdcall calling convention
  • Removed GLFW_ACCELERATED window parameter
  • +
  • Removed default framebuffer attributes from glfwGetWindowParam
  • Bugfix: The default OpenGL version in the glfwinfo test was set to 1.1
  • Bugfix: The OpenGL profile and forward-compatibility window parameters were not saved after context creation
  • Bugfix: The FSAA test did not check for the availability of GL_ARB_multisample
  • diff --git a/src/internal.h b/src/internal.h index 1e4825c0..982d868c 100644 --- a/src/internal.h +++ b/src/internal.h @@ -195,21 +195,6 @@ struct _GLFWwindow char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1]; char key[GLFW_KEY_LAST + 1]; - // Framebuffer attributes - GLint redBits; - GLint greenBits; - GLint blueBits; - GLint alphaBits; - GLint depthBits; - GLint stencilBits; - GLint accumRedBits; - GLint accumGreenBits; - GLint accumBlueBits; - GLint accumAlphaBits; - GLint auxBuffers; - GLboolean stereo; - GLint samples; - // OpenGL extensions and context attributes int glMajor, glMinor, glRevision; GLboolean glForward, glDebug; diff --git a/src/opengl.c b/src/opengl.c index 19c07253..67c6f414 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -406,27 +406,6 @@ GLboolean _glfwRefreshContextParams(void) } } - glGetIntegerv(GL_RED_BITS, &window->redBits); - glGetIntegerv(GL_GREEN_BITS, &window->greenBits); - glGetIntegerv(GL_BLUE_BITS, &window->blueBits); - - glGetIntegerv(GL_ALPHA_BITS, &window->alphaBits); - glGetIntegerv(GL_DEPTH_BITS, &window->depthBits); - glGetIntegerv(GL_STENCIL_BITS, &window->stencilBits); - - glGetIntegerv(GL_ACCUM_RED_BITS, &window->accumRedBits); - glGetIntegerv(GL_ACCUM_GREEN_BITS, &window->accumGreenBits); - glGetIntegerv(GL_ACCUM_BLUE_BITS, &window->accumBlueBits); - glGetIntegerv(GL_ACCUM_ALPHA_BITS, &window->accumAlphaBits); - - glGetIntegerv(GL_AUX_BUFFERS, &window->auxBuffers); - glGetBooleanv(GL_STEREO, &window->stereo); - - if (glfwExtensionSupported("GL_ARB_multisample")) - glGetIntegerv(GL_SAMPLES_ARB, &window->samples); - else - window->samples = 0; - return GL_TRUE; } diff --git a/src/window.c b/src/window.c index f281a256..5fc2b32f 100644 --- a/src/window.c +++ b/src/window.c @@ -662,36 +662,10 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) return window == _glfwLibrary.activeWindow; case GLFW_ICONIFIED: return window->iconified; - case GLFW_RED_BITS: - return window->redBits; - case GLFW_GREEN_BITS: - return window->greenBits; - case GLFW_BLUE_BITS: - return window->blueBits; - case GLFW_ALPHA_BITS: - return window->alphaBits; - case GLFW_DEPTH_BITS: - return window->depthBits; - case GLFW_STENCIL_BITS: - return window->stencilBits; - case GLFW_ACCUM_RED_BITS: - return window->accumRedBits; - case GLFW_ACCUM_GREEN_BITS: - return window->accumGreenBits; - case GLFW_ACCUM_BLUE_BITS: - return window->accumBlueBits; - case GLFW_ACCUM_ALPHA_BITS: - return window->accumAlphaBits; - case GLFW_AUX_BUFFERS: - return window->auxBuffers; - case GLFW_STEREO: - return window->stereo; case GLFW_REFRESH_RATE: return window->refreshRate; case GLFW_WINDOW_RESIZABLE: return window->resizable; - case GLFW_FSAA_SAMPLES: - return window->samples; case GLFW_OPENGL_VERSION_MAJOR: return window->glMajor; case GLFW_OPENGL_VERSION_MINOR: diff --git a/tests/defaults.c b/tests/defaults.c index 289e2c60..fc7b96cc 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -34,33 +34,45 @@ #include #include +#ifndef GL_ARB_multisample + #define GL_SAMPLES_ARB 0x80A9 +#endif + +typedef struct +{ + int param; + char* ext; + char* name; +} ParamGL; + typedef struct { int param; char* name; -} Param; +} ParamGLFW; -static Param parameters[] = +static ParamGL gl_params[] = +{ + { GL_RED_BITS, NULL, "red bits" }, + { GL_GREEN_BITS, NULL, "green bits" }, + { GL_BLUE_BITS, NULL, "blue bits" }, + { GL_ALPHA_BITS, NULL, "alpha bits" }, + { GL_DEPTH_BITS, NULL, "depth bits" }, + { GL_STENCIL_BITS, NULL, "stencil bits" }, + { GL_STEREO, NULL, "stereo" }, + { GL_SAMPLES_ARB, "GL_ARB_multisample", "FSAA samples" }, + { 0, NULL, NULL } +}; + +static ParamGLFW glfw_params[] = { - { GLFW_RED_BITS, "red bits" }, - { GLFW_GREEN_BITS, "green bits" }, - { GLFW_BLUE_BITS, "blue bits" }, - { GLFW_ALPHA_BITS, "alpha bits" }, - { GLFW_DEPTH_BITS, "depth bits" }, - { GLFW_STENCIL_BITS, "stencil bits" }, { GLFW_REFRESH_RATE, "refresh rate" }, - { GLFW_ACCUM_RED_BITS, "accum red bits" }, - { GLFW_ACCUM_GREEN_BITS, "accum green bits" }, - { GLFW_ACCUM_BLUE_BITS, "accum blue bits" }, - { GLFW_ACCUM_ALPHA_BITS, "accum alpha bits" }, - { GLFW_AUX_BUFFERS, "aux buffers" }, - { GLFW_STEREO, "stereo" }, - { GLFW_FSAA_SAMPLES, "FSAA samples" }, { GLFW_OPENGL_VERSION_MAJOR, "OpenGL major" }, { GLFW_OPENGL_VERSION_MINOR, "OpenGL minor" }, { GLFW_OPENGL_FORWARD_COMPAT, "OpenGL forward compatible" }, { GLFW_OPENGL_DEBUG_CONTEXT, "OpenGL debug context" }, { GLFW_OPENGL_PROFILE, "OpenGL profile" }, + { 0, NULL } }; int main(void) @@ -87,11 +99,26 @@ int main(void) printf("window size: %ix%i\n", width, height); - for (i = 0; (size_t) i < sizeof(parameters) / sizeof(parameters[0]); i++) + for (i = 0; glfw_params[i].name; i++) { printf("%s: %i\n", - parameters[i].name, - glfwGetWindowParam(window, parameters[i].param)); + glfw_params[i].name, + glfwGetWindowParam(window, glfw_params[i].param)); + } + + for (i = 0; gl_params[i].name; i++) + { + GLint value = 0; + + if (gl_params[i].ext) + { + if (!glfwExtensionSupported(gl_params[i].ext)) + continue; + } + + glGetIntegerv(gl_params[i].param, &value); + + printf("%s: %i\n", gl_params[i].name, value); } glfwDestroyWindow(window); diff --git a/tests/fsaa.c b/tests/fsaa.c index e2e0623c..93377b59 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -117,7 +117,7 @@ int main(int argc, char** argv) glfwSwapInterval(1); - samples = glfwGetWindowParam(window, GLFW_FSAA_SAMPLES); + glGetIntegerv(GL_SAMPLES_ARB, &samples); if (samples) printf("Context reports FSAA is available with %i samples\n", samples); else diff --git a/tests/modes.c b/tests/modes.c index eeb83abf..2293a399 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -114,7 +114,7 @@ static void list_modes(void) static void test_modes(void) { - int i, count, width, height; + int i, count; GLFWvidmode* modes = glfwGetVideoModes(&count); glfwSetWindowSizeCallback(window_size_callback); @@ -124,6 +124,7 @@ static void test_modes(void) for (i = 0; i < count; i++) { GLFWvidmode* mode = modes + i; + GLFWvidmode current; glfwWindowHint(GLFW_RED_BITS, mode->redBits); glfwWindowHint(GLFW_GREEN_BITS, mode->greenBits); @@ -158,25 +159,25 @@ static void test_modes(void) } } - if (glfwGetWindowParam(window, GLFW_RED_BITS) != mode->redBits || - glfwGetWindowParam(window, GLFW_GREEN_BITS) != mode->greenBits || - glfwGetWindowParam(window, GLFW_BLUE_BITS) != mode->blueBits) + glGetIntegerv(GL_RED_BITS, ¤t.redBits); + glGetIntegerv(GL_GREEN_BITS, ¤t.greenBits); + glGetIntegerv(GL_BLUE_BITS, ¤t.blueBits); + + glfwGetWindowSize(window, ¤t.width, ¤t.height); + + if (current.redBits != mode->redBits || + current.greenBits != mode->greenBits || + current.blueBits != mode->blueBits) { printf("*** Color bit mismatch: (%i %i %i) instead of (%i %i %i)\n", - glfwGetWindowParam(window, GLFW_RED_BITS), - glfwGetWindowParam(window, GLFW_GREEN_BITS), - glfwGetWindowParam(window, GLFW_BLUE_BITS), - mode->redBits, - mode->greenBits, - mode->blueBits); + current.redBits, current.greenBits, current.blueBits, + mode->redBits, mode->greenBits, mode->blueBits); } - glfwGetWindowSize(window, &width, &height); - - if (width != mode->width || height != mode->height) + if (current.width != mode->width || current.height != mode->height) { printf("*** Size mismatch: %ix%i instead of %ix%i\n", - width, height, + current.width, current.height, mode->width, mode->height); } From 2212cd94bfadb2f017ee41bf97906b8ed6af7fa0 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 10 Aug 2012 13:29:45 +0200 Subject: [PATCH 13/29] Moved glfwWindowHint to the top of its block. --- include/GL/glfw3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 45dd1aad..d5a55fdd 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -529,8 +529,8 @@ GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp); GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp); /* Window handling */ -GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share); GLFWAPI void glfwWindowHint(int target, int hint); +GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, int mode, const char* title, GLFWwindow share); GLFWAPI void glfwDestroyWindow(GLFWwindow window); GLFWAPI void glfwSetWindowTitle(GLFWwindow, const char* title); GLFWAPI void glfwGetWindowSize(GLFWwindow, int* width, int* height); From 2410e2aaf4318f418f322ba9c856b9423e84bb7b Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 10 Aug 2012 13:31:15 +0200 Subject: [PATCH 14/29] Replaced automatic closing with window parameter. --- examples/boing.c | 19 ++++--------------- examples/splitview.c | 26 ++++++-------------------- examples/triangle.c | 21 ++++++--------------- include/GL/glfw3.h | 1 + readme.html | 1 + src/cocoa_window.m | 5 ++--- src/internal.h | 1 + src/win32_window.c | 5 ++--- src/window.c | 44 +++++++++++++++----------------------------- src/x11_window.c | 2 +- tests/accuracy.c | 2 +- tests/clipboard.c | 2 +- tests/events.c | 8 +------- tests/fsaa.c | 2 +- tests/gamma.c | 2 +- tests/iconify.c | 2 +- tests/joysticks.c | 2 +- tests/peter.c | 2 +- tests/tearing.c | 2 +- tests/title.c | 2 +- tests/windows.c | 14 ++++---------- 21 files changed, 53 insertions(+), 112 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 8348df66..c0d3f0ee 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -89,7 +89,6 @@ DRAW_BALL_ENUM drawBallHow; double t; double t_old = 0.f; double dt; -static GLboolean running = GL_TRUE; /* Random number generator */ #ifndef RAND_MAX @@ -246,16 +245,6 @@ void reshape( GLFWwindow window, int w, int h ) } -/***************************************************************************** - * Window close callback - *****************************************************************************/ -static int window_close_callback(GLFWwindow window) -{ - running = GL_FALSE; - return GL_TRUE; -} - - /***************************************************************************** * Draw the Boing ball. * @@ -588,7 +577,6 @@ int main( void ) exit( EXIT_FAILURE ); } - glfwSetWindowCloseCallback( window_close_callback ); glfwSetWindowSizeCallback( reshape ); glfwWindowHint(GLFW_DEPTH_BITS, 16); @@ -611,7 +599,7 @@ int main( void ) init(); /* Main loop */ - do + for (;;) { /* Timing */ t = glfwGetTime(); @@ -627,9 +615,10 @@ int main( void ) /* Check if we are still running */ if (glfwGetKey( window, GLFW_KEY_ESCAPE )) - running = GL_FALSE; + break; + if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) + break; } - while( running ); glfwTerminate(); exit( EXIT_SUCCESS ); diff --git a/examples/splitview.c b/examples/splitview.c index e3f01806..2f53f45d 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -42,9 +42,6 @@ static int rot_x = 0, rot_y = 0, rot_z = 0; // Do redraw? static int do_redraw = 1; -// Keep running? -static GLboolean running = GL_TRUE; - //======================================================================== // Draw a solid torus (use a display list for the model) @@ -438,17 +435,6 @@ static void mouseButtonFun(GLFWwindow window, int button, int action) } -//======================================================================== -// Window close callback function -//======================================================================== - -static int windowCloseFun(GLFWwindow window) -{ - running = GL_FALSE; - return GL_TRUE; -} - - //======================================================================== // main //======================================================================== @@ -466,7 +452,6 @@ int main(void) } // Set callback functions - glfwSetWindowCloseCallback(windowCloseFun); glfwSetWindowSizeCallback(windowSizeFun); glfwSetWindowRefreshCallback(windowRefreshFun); glfwSetCursorPosCallback(cursorPosFun); @@ -495,7 +480,7 @@ int main(void) glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); // Main loop - do + for (;;) { // Only redraw if we need to if (do_redraw) @@ -512,11 +497,12 @@ int main(void) // Wait for new events glfwWaitEvents(); + // Check if the ESC key was pressed or the window should be closed if (glfwGetKey(window, GLFW_KEY_ESCAPE)) - running = GL_FALSE; - - } // Check if the ESC key was pressed or the window was closed - while (running); + break; + if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) + break; + } // Close OpenGL window and terminate GLFW glfwTerminate(); diff --git a/examples/triangle.c b/examples/triangle.c index 8a352ca9..9ebfbcac 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -10,14 +10,6 @@ #define GLFW_INCLUDE_GLU #include -static GLboolean running = GL_TRUE; - -static int window_close_callback(GLFWwindow window) -{ - running = GL_FALSE; - return GL_TRUE; -} - int main(void) { int width, height, x; @@ -44,9 +36,7 @@ int main(void) // Enable vertical sync (on cards that support it) glfwSwapInterval(1); - glfwSetWindowCloseCallback(window_close_callback); - - do + for (;;) { double t = glfwGetTime(); glfwGetCursorPos(window, &x, NULL); @@ -92,11 +82,12 @@ int main(void) glfwSwapBuffers(window); glfwPollEvents(); + // Check if the ESC key was pressed or the window should be closed if (glfwGetKey(window, GLFW_KEY_ESCAPE)) - running = GL_FALSE; - - } // Check if the ESC key was pressed or the window was closed - while (running); + break; + if (glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) + break; + } // Close OpenGL window and terminate GLFW glfwTerminate(); diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index d5a55fdd..050f0c30 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -388,6 +388,7 @@ extern "C" { /* glfwGetWindowParam tokens */ #define GLFW_ACTIVE 0x00020001 #define GLFW_ICONIFIED 0x00020002 +#define GLFW_CLOSE_REQUESTED 0x00020003 #define GLFW_OPENGL_REVISION 0x00020004 /* glfwWindowHint tokens */ diff --git a/readme.html b/readme.html index b93b7c6b..39d0739b 100644 --- a/readme.html +++ b/readme.html @@ -307,6 +307,7 @@ version of GLFW.

  • Replaced mouse wheel interface with two-dimensional, floating point scrolling interface
  • Replaced glfwEnable and glfwDisable with glfwGetInputMode and glfwSetInputMode
  • Replaced joystick test with graphical version
  • +
  • Replaced automatic closing of windows with GLFW_CLOSE_REQUESTED window parameter
  • Made Unicode character input unaffected by GLFW_KEY_REPEAT
  • Removed event auto-polling and the GLFW_AUTO_POLL_EVENTS window enable
  • Removed the Win32 port .def files
  • diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 0d8ec67d..446d718e 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -59,8 +59,7 @@ - (BOOL)windowShouldClose:(id)sender { - window->closeRequested = GL_TRUE; - + _glfwInputWindowCloseRequest(window); return NO; } @@ -127,7 +126,7 @@ _GLFWwindow* window; for (window = _glfwLibrary.windowListHead; window; window = window->next) - window->closeRequested = GL_TRUE; + _glfwInputWindowCloseRequest(window); return NSTerminateCancel; } diff --git a/src/internal.h b/src/internal.h index 982d868c..89ac48b2 100644 --- a/src/internal.h +++ b/src/internal.h @@ -337,6 +337,7 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y); void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); void _glfwInputWindowIconify(_GLFWwindow* window, int iconified); void _glfwInputWindowDamage(_GLFWwindow* window); +void _glfwInputWindowCloseRequest(_GLFWwindow* window); // Input event notification (input.c) void _glfwInputKey(_GLFWwindow* window, int key, int action); diff --git a/src/win32_window.c b/src/win32_window.c index 62a53c03..00fb269d 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -532,8 +532,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_CLOSE: { - // Flag this window for closing (handled in glfwPollEvents) - window->closeRequested = GL_TRUE; + _glfwInputWindowCloseRequest(window); return 0; } @@ -1249,7 +1248,7 @@ void _glfwPlatformPollEvents(void) window = _glfwLibrary.windowListHead; while (window) { - window->closeRequested = GL_TRUE; + _glfwInputWindowCloseRequest(window); window = window->next; } diff --git a/src/window.c b/src/window.c index 5fc2b32f..81b525bd 100644 --- a/src/window.c +++ b/src/window.c @@ -44,31 +44,6 @@ static int Max(int a, int b) } -//======================================================================== -// Close all GLFW windows with the closed flag set -//======================================================================== - -static void closeFlaggedWindows(void) -{ - _GLFWwindow* window; - - for (window = _glfwLibrary.windowListHead; window; ) - { - if (window->closeRequested && _glfwLibrary.windowCloseCallback) - window->closeRequested = _glfwLibrary.windowCloseCallback(window); - - if (window->closeRequested) - { - _GLFWwindow* next = window->next; - glfwDestroyWindow(window); - window = next; - } - else - window = window->next; - } -} - - //======================================================================== // Clear scroll offsets for all windows //======================================================================== @@ -206,6 +181,19 @@ void _glfwInputWindowDamage(_GLFWwindow* window) } +//======================================================================== +// Register window close request events +//======================================================================== + +void _glfwInputWindowCloseRequest(_GLFWwindow* window) +{ + if (_glfwLibrary.windowCloseCallback) + window->closeRequested = _glfwLibrary.windowCloseCallback(window); + else + window->closeRequested = GL_TRUE; +} + + ////////////////////////////////////////////////////////////////////////// ////// GLFW public API ////// ////////////////////////////////////////////////////////////////////////// @@ -662,6 +650,8 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param) return window == _glfwLibrary.activeWindow; case GLFW_ICONIFIED: return window->iconified; + case GLFW_CLOSE_REQUESTED: + return window->closeRequested; case GLFW_REFRESH_RATE: return window->refreshRate; case GLFW_WINDOW_RESIZABLE: @@ -818,8 +808,6 @@ GLFWAPI void glfwPollEvents(void) clearScrollOffsets(); _glfwPlatformPollEvents(); - - closeFlaggedWindows(); } @@ -838,7 +826,5 @@ GLFWAPI void glfwWaitEvents(void) clearScrollOffsets(); _glfwPlatformWaitEvents(); - - closeFlaggedWindows(); } diff --git a/src/x11_window.c b/src/x11_window.c index e90790f7..05d1be83 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -711,7 +711,7 @@ static void processSingleEvent(void) // The window manager was asked to close the window, for example by // the user pressing a 'close' window decoration button - window->closeRequested = GL_TRUE; + _glfwInputWindowCloseRequest(window); } else if (_glfwLibrary.X11.wmPing != None && (Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing) diff --git a/tests/accuracy.c b/tests/accuracy.c index 079a88b8..acf9be2f 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -106,7 +106,7 @@ int main(void) set_swap_interval(window, swap_interval); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/clipboard.c b/tests/clipboard.c index 8ab90dbb..654de5f9 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -136,7 +136,7 @@ int main(int argc, char** argv) glClearColor(0.5f, 0.5f, 0.5f, 0); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/events.c b/tests/events.c index bd8b1546..20051a24 100644 --- a/tests/events.c +++ b/tests/events.c @@ -48,9 +48,6 @@ static GLboolean closeable = GL_TRUE; // Event index static unsigned int counter = 0; -// Should we keep running? -static GLboolean running = GL_TRUE; - static const char* get_key_name(int key) { switch (key) @@ -238,9 +235,6 @@ static int window_close_callback(GLFWwindow window) { printf("%08x at %0.3f: Window close\n", counter++, glfwGetTime()); - if (closeable) - running = GL_FALSE; - return closeable; } @@ -399,7 +393,7 @@ int main(void) printf("Main loop starting\n"); - while (running) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) glfwWaitEvents(); glfwTerminate(); diff --git a/tests/fsaa.c b/tests/fsaa.c index 93377b59..2a9ccfb5 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -127,7 +127,7 @@ int main(int argc, char** argv) gluOrtho2D(0.f, 1.f, 0.f, 0.5f); glMatrixMode(GL_MODELVIEW); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { GLfloat time = (GLfloat) glfwGetTime(); diff --git a/tests/gamma.c b/tests/gamma.c index 1f3ca5e1..b2f1f2b8 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -151,7 +151,7 @@ int main(int argc, char** argv) glClearColor(0.5f, 0.5f, 0.5f, 0); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/iconify.c b/tests/iconify.c index 4f1c7d22..221d558f 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -126,7 +126,7 @@ int main(int argc, char** argv) glEnable(GL_SCISSOR_TEST); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { int width, height; diff --git a/tests/joysticks.c b/tests/joysticks.c index 36952038..374ec82d 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -198,7 +198,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/peter.c b/tests/peter.c index 7e0be921..be772e94 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -127,7 +127,7 @@ int main(void) glClearColor(0.f, 0.f, 0.f, 0.f); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window_handle, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/tearing.c b/tests/tearing.c index 19ffe531..51e110ac 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -90,7 +90,7 @@ int main(void) glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f); glMatrixMode(GL_MODELVIEW); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/title.c b/tests/title.c index 918d7eed..1370b338 100644 --- a/tests/title.c +++ b/tests/title.c @@ -58,7 +58,7 @@ int main(void) glfwSetWindowSizeCallback(window_size_callback); - while (glfwGetCurrentContext()) + while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(window); diff --git a/tests/windows.c b/tests/windows.c index 27c1bd30..ce0609af 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -32,14 +32,6 @@ #include #include -static GLboolean running = GL_TRUE; - -static int window_close_callback(GLFWwindow window) -{ - running = GL_FALSE; - return GL_TRUE; -} - static const char* titles[] = { "Foo", @@ -51,6 +43,7 @@ static const char* titles[] = int main(void) { int i; + GLboolean running = GL_TRUE; GLFWwindow windows[4]; if (!glfwInit()) @@ -60,8 +53,6 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetWindowCloseCallback(window_close_callback); - for (i = 0; i < 4; i++) { windows[i] = glfwCreateWindow(200, 200, GLFW_WINDOWED, titles[i], NULL); @@ -88,6 +79,9 @@ int main(void) glfwMakeContextCurrent(windows[i]); glClear(GL_COLOR_BUFFER_BIT); glfwSwapBuffers(windows[i]); + + if (glfwGetWindowParam(windows[i], GLFW_CLOSE_REQUESTED)) + running = GL_FALSE; } glfwPollEvents(); From 2f095cc9e3ec8f1cf981f7484b1871731cba7b51 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Fri, 10 Aug 2012 15:29:45 +0200 Subject: [PATCH 15/29] Removed implicit glfwMakeCurrentContext. Implicitly making the context current makes sense in a single-window API but less sense in a multi-window one. --- examples/boing.c | 4 +++- examples/gears.c | 4 +++- examples/heightmap.c | 4 +++- examples/splitview.c | 7 ++++--- examples/triangle.c | 7 ++++--- examples/wave.c | 5 +++-- src/window.c | 10 ++++++++++ tests/accuracy.c | 2 ++ tests/clipboard.c | 2 ++ tests/defaults.c | 1 + tests/events.c | 1 + tests/fsaa.c | 5 +++-- tests/fsfocus.c | 2 ++ tests/gamma.c | 2 ++ tests/glfwinfo.c | 2 ++ tests/iconify.c | 2 ++ tests/joysticks.c | 2 ++ tests/modes.c | 4 +++- tests/peter.c | 4 +++- tests/reopen.c | 4 +++- tests/sharing.c | 4 +++- tests/tearing.c | 1 + tests/title.c | 1 + tests/windows.c | 5 +++-- 24 files changed, 66 insertions(+), 19 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index c0d3f0ee..3cc09730 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -589,11 +589,13 @@ int main( void ) exit( EXIT_FAILURE ); } + glfwMakeContextCurrent(window); + glfwSwapInterval( 1 ); + glfwGetWindowSize(window, &width, &height); reshape(window, width, height); glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE ); - glfwSwapInterval( 1 ); glfwSetTime( 0.0 ); init(); diff --git a/examples/gears.c b/examples/gears.c index ccc06867..cd3cdbb1 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -353,11 +353,13 @@ int main(int argc, char *argv[]) exit( EXIT_FAILURE ); } + glfwMakeContextCurrent(window); + glfwSwapInterval( 1 ); + glfwGetWindowSize(window, &width, &height); reshape(window, width, height); glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE ); - glfwSwapInterval( 1 ); // Parse command-line options init(argc, argv); diff --git a/examples/heightmap.c b/examples/heightmap.c index ce894f99..fce8b8de 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -597,10 +597,12 @@ int main(int argc, char** argv) free(fragment_shader_src); exit(EXIT_FAILURE); } + + /* Register events callback */ glfwSetWindowCloseCallback(window_close_callback); glfwSetKeyCallback(key_callback); - /* Register events callback */ + glfwMakeContextCurrent(window); if (GL_TRUE != init_opengl()) { fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n"); diff --git a/examples/splitview.c b/examples/splitview.c index 2f53f45d..c602d0c4 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -467,12 +467,13 @@ int main(void) exit(EXIT_FAILURE); } + // Enable vsync + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + glfwGetWindowSize(window, &width, &height); windowSizeFun(window, width, height); - // Enable vsync - glfwSwapInterval(1); - // Enable sticky keys glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); diff --git a/examples/triangle.c b/examples/triangle.c index 9ebfbcac..615483a9 100644 --- a/examples/triangle.c +++ b/examples/triangle.c @@ -30,12 +30,13 @@ int main(void) exit(EXIT_FAILURE); } + // Enable vertical sync (on cards that support it) + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + // Ensure we can capture the escape key being pressed below glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE); - // Enable vertical sync (on cards that support it) - glfwSwapInterval(1); - for (;;) { double t = glfwGetTime(); diff --git a/examples/wave.c b/examples/wave.c index e0c687d6..668d54bd 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -413,11 +413,12 @@ int main(int argc, char* argv[]) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + glfwGetWindowSize(window, &width, &height); window_size_callback(window, width, height); - glfwSwapInterval(1); - glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE); // Initialize OpenGL diff --git a/src/window.c b/src/window.c index 81b525bd..df592751 100644 --- a/src/window.c +++ b/src/window.c @@ -209,6 +209,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, _GLFWfbconfig fbconfig; _GLFWwndconfig wndconfig; _GLFWwindow* window; + _GLFWwindow* previous; if (!_glfwInitialized) { @@ -254,6 +255,9 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (!_glfwIsValidContextConfig(&wndconfig)) return GL_FALSE; + // Save the currently current context so it can be restored later + previous = glfwGetCurrentContext(); + if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN) { _glfwSetError(GLFW_INVALID_ENUM, @@ -303,6 +307,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig)) { glfwDestroyWindow(window); + glfwMakeContextCurrent(previous); return GL_FALSE; } @@ -314,6 +319,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (!_glfwRefreshContextParams()) { glfwDestroyWindow(window); + glfwMakeContextCurrent(previous); return GL_FALSE; } @@ -321,9 +327,13 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, if (!_glfwIsValidContext(&wndconfig)) { glfwDestroyWindow(window); + glfwMakeContextCurrent(previous); return GL_FALSE; } + // Restore the previously current context (or NULL) + glfwMakeContextCurrent(previous); + // The GLFW specification states that fullscreen windows have the cursor // captured by default if (mode == GLFW_FULLSCREEN) diff --git a/tests/accuracy.c b/tests/accuracy.c index acf9be2f..30235a5e 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -101,6 +101,8 @@ int main(void) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); + glfwGetWindowSize(window, &width, &height); window_size_callback(window, width, height); diff --git a/tests/clipboard.c b/tests/clipboard.c index 654de5f9..fcd1c307 100644 --- a/tests/clipboard.c +++ b/tests/clipboard.c @@ -126,7 +126,9 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); glfwSwapInterval(1); + glfwSetKeyCallback(key_callback); glfwSetWindowSizeCallback(size_callback); diff --git a/tests/defaults.c b/tests/defaults.c index fc7b96cc..5e3f3890 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -95,6 +95,7 @@ int main(void) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); glfwGetWindowSize(window, &width, &height); printf("window size: %ix%i\n", width, height); diff --git a/tests/events.c b/tests/events.c index 20051a24..f82b8fc9 100644 --- a/tests/events.c +++ b/tests/events.c @@ -383,6 +383,7 @@ int main(void) printf("Window opened\n"); + glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwGetWindowSize(window, &width, &height); diff --git a/tests/fsaa.c b/tests/fsaa.c index 2a9ccfb5..8fc8b60a 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -107,6 +107,9 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + if (!glfwExtensionSupported("GL_ARB_multisample")) { glfwTerminate(); @@ -115,8 +118,6 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } - glfwSwapInterval(1); - glGetIntegerv(GL_SAMPLES_ARB, &samples); if (samples) printf("Context reports FSAA is available with %i samples\n", samples); diff --git a/tests/fsfocus.c b/tests/fsfocus.c index e718a319..1c46d7af 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -91,7 +91,9 @@ int main(void) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); glfwSwapInterval(1); + glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL); glfwSetWindowFocusCallback(window_focus_callback); diff --git a/tests/gamma.c b/tests/gamma.c index b2f1f2b8..7d93ed06 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -141,7 +141,9 @@ int main(int argc, char** argv) set_gamma(1.f); + glfwMakeContextCurrent(window); glfwSwapInterval(1); + glfwSetKeyCallback(key_callback); glfwSetWindowSizeCallback(size_callback); diff --git a/tests/glfwinfo.c b/tests/glfwinfo.c index 4990ff09..90fd329f 100644 --- a/tests/glfwinfo.c +++ b/tests/glfwinfo.c @@ -214,6 +214,8 @@ int main(int argc, char** argv) if (!window) exit(EXIT_FAILURE); + glfwMakeContextCurrent(window); + // Report GLFW version glfwGetVersion(&major, &minor, &revision); diff --git a/tests/iconify.c b/tests/iconify.c index 221d558f..d1a505b5 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -120,7 +120,9 @@ int main(int argc, char** argv) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); glfwSwapInterval(1); + glfwSetKeyCallback(key_callback); glfwSetWindowSizeCallback(size_callback); diff --git a/tests/joysticks.c b/tests/joysticks.c index 374ec82d..488f98ad 100644 --- a/tests/joysticks.c +++ b/tests/joysticks.c @@ -196,6 +196,8 @@ int main(void) } glfwSetWindowSizeCallback(window_size_callback); + + glfwMakeContextCurrent(window); glfwSwapInterval(1); while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) diff --git a/tests/modes.c b/tests/modes.c index 2293a399..660f89d5 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -143,9 +143,11 @@ static void test_modes(void) continue; } - glfwSetTime(0.0); + glfwMakeContextCurrent(window); glfwSwapInterval(1); + glfwSetTime(0.0); + while (glfwGetTime() < 5.0) { glClear(GL_COLOR_BUFFER_BIT); diff --git a/tests/peter.c b/tests/peter.c index be772e94..ae6e4b7d 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -98,13 +98,15 @@ static GLboolean open_window(void) if (!window_handle) return GL_FALSE; + glfwMakeContextCurrent(window_handle); + glfwSwapInterval(1); + glfwGetCursorPos(window_handle, &cursor_x, &cursor_y); printf("Cursor position: %i %i\n", cursor_x, cursor_y); glfwSetWindowSizeCallback(window_size_callback); glfwSetCursorPosCallback(cursor_position_callback); glfwSetKeyCallback(key_callback); - glfwSwapInterval(1); return GL_TRUE; } diff --git a/tests/reopen.c b/tests/reopen.c index 545ba280..5d137188 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -99,10 +99,12 @@ static GLboolean open_window(int width, int height, int mode) return GL_FALSE; } + glfwMakeContextCurrent(window_handle); + glfwSwapInterval(1); + glfwSetWindowSizeCallback(window_size_callback); glfwSetWindowCloseCallback(window_close_callback); glfwSetKeyCallback(key_callback); - glfwSwapInterval(1); printf("Opening %s mode window took %0.3f seconds\n", get_mode_name(mode), diff --git a/tests/sharing.c b/tests/sharing.c index 8031a9bb..95f21342 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -68,9 +68,11 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) if (!window) return NULL; + glfwMakeContextCurrent(window); + glfwSwapInterval(1); + glfwSetWindowCloseCallback(window_close_callback); glfwSetKeyCallback(key_callback); - glfwSwapInterval(1); return window; } diff --git a/tests/tearing.c b/tests/tearing.c index 51e110ac..c2349c88 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -81,6 +81,7 @@ int main(void) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); set_swap_interval(window, swap_interval); glfwSetWindowSizeCallback(window_size_callback); diff --git a/tests/title.c b/tests/title.c index 1370b338..c7539033 100644 --- a/tests/title.c +++ b/tests/title.c @@ -54,6 +54,7 @@ int main(void) exit(EXIT_FAILURE); } + glfwMakeContextCurrent(window); glfwSwapInterval(1); glfwSetWindowSizeCallback(window_size_callback); diff --git a/tests/windows.c b/tests/windows.c index ce0609af..7b1a529c 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -64,12 +64,13 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); - + glfwMakeContextCurrent(windows[i]); glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), i ? 0.0 : 1.0, 0.0); + + glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); } while (running) From 31c0212c25a777b03461a8e833e60a895dc88ba0 Mon Sep 17 00:00:00 2001 From: jonathan MERCIER Date: Sat, 11 Aug 2012 17:50:56 +0200 Subject: [PATCH 16/29] Able to install to lib64 if LIB_SUFFIX var is set to 64 --- CMakeLists.txt | 3 ++- src/CMakeLists.txt | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d49a2aea..27a609a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ set(GLFW_VERSION_PATCH "0") set(GLFW_VERSION_EXTRA "") set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}") set(GLFW_VERSION_FULL "${GLFW_VERSION}.${GLFW_VERSION_PATCH}${GLFW_VERSION_EXTRA}") +set(LIB_SUFFIX "" CACHE STRING "Takes an empty string or 64. Directory where lib will be installed: lib or lib64") option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" ON) option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON) @@ -265,7 +266,7 @@ if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL) ${GLFW_BINARY_DIR}/src/libglfw3.pc @ONLY) install(FILES ${GLFW_BINARY_DIR}/src/libglfw3.pc - DESTINATION lib/pkgconfig) + DESTINATION lib${LIB_SUFFIX}/pkgconfig) endif() #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 926ef668..f204a639 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,3 @@ - include_directories(${GLFW_SOURCE_DIR}/src ${GLFW_BINARY_DIR}/src ${glfw_INCLUDE_DIRS}) @@ -59,5 +58,5 @@ if (BUILD_SHARED_LIBS) target_link_libraries(glfw LINK_INTERFACE_LIBRARIES) endif() -install(TARGETS glfw DESTINATION lib) +install(TARGETS glfw DESTINATION lib${LIB_SUFFIX} ) From 704e56fc81cbe1adc92ff5d08456404a5600bc79 Mon Sep 17 00:00:00 2001 From: Lambert Clara Date: Sun, 12 Aug 2012 12:29:55 +0200 Subject: [PATCH 17/29] Fix compilation with MSVC by using sprintf instead of snprintf snprintf is part of c99 standard, not supported by MS compilers --- tests/accuracy.c | 6 +++--- tests/modes.c | 10 +++++----- tests/tearing.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/accuracy.c b/tests/accuracy.c index 30235a5e..c9a82ec7 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -46,9 +46,9 @@ static void set_swap_interval(GLFWwindow window, int interval) swap_interval = interval; glfwSwapInterval(swap_interval); - snprintf(title, sizeof(title), - "Cursor Inaccuracy Detector (interval %i)", - swap_interval); + sprintf(title, + "Cursor Inaccuracy Detector (interval %i)", + swap_interval); glfwSetWindowTitle(window, title); } diff --git a/tests/modes.c b/tests/modes.c index 660f89d5..b5912ed7 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -53,11 +53,11 @@ static const char* format_mode(GLFWvidmode* mode) { static char buffer[512]; - snprintf(buffer, sizeof(buffer), - "%i x %i x %i (%i %i %i)", - mode->width, mode->height, - mode->redBits + mode->greenBits + mode->blueBits, - mode->redBits, mode->greenBits, mode->blueBits); + sprintf(buffer, + "%i x %i x %i (%i %i %i)", + mode->width, mode->height, + mode->redBits + mode->greenBits + mode->blueBits, + mode->redBits, mode->greenBits, mode->blueBits); buffer[sizeof(buffer) - 1] = '\0'; return buffer; diff --git a/tests/tearing.c b/tests/tearing.c index c2349c88..165ec01c 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -43,9 +43,9 @@ static void set_swap_interval(GLFWwindow window, int interval) swap_interval = interval; glfwSwapInterval(swap_interval); - snprintf(title, sizeof(title), - "Tearing detector (interval %i)", - swap_interval); + sprintf(title, + "Tearing detector (interval %i)", + swap_interval); glfwSetWindowTitle(window, title); } From 5bbac6fe69caa793c2cd5f95473f4bf7cd1a31e3 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 12:44:23 +0200 Subject: [PATCH 18/29] Moved Free Getopt files to support directory. --- examples/CMakeLists.txt | 5 +- examples/getopt.c | 259 --------------------------------- {tests => support}/getopt.c | 0 {examples => support}/getopt.h | 0 tests/CMakeLists.txt | 15 +- tests/getopt.h | 63 -------- 6 files changed, 13 insertions(+), 329 deletions(-) delete mode 100644 examples/getopt.c rename {tests => support}/getopt.c (100%) rename {examples => support}/getopt.h (100%) delete mode 100644 tests/getopt.h diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3e7065c6..a3c26beb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,6 +12,9 @@ include_directories(${GLFW_SOURCE_DIR}/include ${GLFW_SOURCE_DIR}/support ${OPENGL_INCLUDE_DIR}) +set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h + ${GLFW_SOURCE_DIR}/support/getopt.c) + if (APPLE) # Set fancy names for bundles add_executable(Boing MACOSX_BUNDLE boing.c) @@ -29,7 +32,7 @@ else() # Set boring names for executables add_executable(boing WIN32 boing.c) add_executable(gears WIN32 gears.c) - add_executable(heightmap WIN32 heightmap.c getopt.c) + add_executable(heightmap WIN32 heightmap.c ${GETOPT}) add_executable(splitview WIN32 splitview.c) add_executable(triangle WIN32 triangle.c) add_executable(wave WIN32 wave.c) diff --git a/examples/getopt.c b/examples/getopt.c deleted file mode 100644 index 9d79b9a7..00000000 --- a/examples/getopt.c +++ /dev/null @@ -1,259 +0,0 @@ -/***************************************************************************** -* getopt.c - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.c,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#define _CRT_SECURE_NO_WARNINGS - -#include -#include -#include -#include "getopt.h" - - -/* 2011-07-27 Camilla Berglund - * - * Added _CRT_SECURE_NO_WARNINGS macro. - */ -/* 2009-10-12 Camilla Berglund - * - * Removed unused global static variable 'ID'. - */ - - -char* optarg = NULL; -int optind = 0; -int opterr = 1; -int optopt = '?'; - - -static char** prev_argv = NULL; /* Keep a copy of argv and argc to */ -static int prev_argc = 0; /* tell if getopt params change */ -static int argv_index = 0; /* Option we're checking */ -static int argv_index2 = 0; /* Option argument we're checking */ -static int opt_offset = 0; /* Index into compounded "-option" */ -static int dashdash = 0; /* True if "--" option reached */ -static int nonopt = 0; /* How many nonopts we've found */ - -static void increment_index() -{ - /* Move onto the next option */ - if(argv_index < argv_index2) - { - while(prev_argv[++argv_index] && prev_argv[argv_index][0] != '-' - && argv_index < argv_index2+1); - } - else argv_index++; - opt_offset = 1; -} - - -/* -* Permutes argv[] so that the argument currently being processed is moved -* to the end. -*/ -static int permute_argv_once() -{ - /* Movability check */ - if(argv_index + nonopt >= prev_argc) return 1; - /* Move the current option to the end, bring the others to front */ - else - { - char* tmp = prev_argv[argv_index]; - - /* Move the data */ - memmove(&prev_argv[argv_index], &prev_argv[argv_index+1], - sizeof(char**) * (prev_argc - argv_index - 1)); - prev_argv[prev_argc - 1] = tmp; - - nonopt++; - return 0; - } -} - - -int getopt(int argc, char** argv, char* optstr) -{ - int c = 0; - - /* If we have new argv, reinitialize */ - if(prev_argv != argv || prev_argc != argc) - { - /* Initialize variables */ - prev_argv = argv; - prev_argc = argc; - argv_index = 1; - argv_index2 = 1; - opt_offset = 1; - dashdash = 0; - nonopt = 0; - } - - /* Jump point in case we want to ignore the current argv_index */ - getopt_top: - - /* Misc. initializations */ - optarg = NULL; - - /* Dash-dash check */ - if(argv[argv_index] && !strcmp(argv[argv_index], "--")) - { - dashdash = 1; - increment_index(); - } - - /* If we're at the end of argv, that's it. */ - if(argv[argv_index] == NULL) - { - c = -1; - } - /* Are we looking at a string? Single dash is also a string */ - else if(dashdash || argv[argv_index][0] != '-' || !strcmp(argv[argv_index], "-")) - { - /* If we want a string... */ - if(optstr[0] == '-') - { - c = 1; - optarg = argv[argv_index]; - increment_index(); - } - /* If we really don't want it (we're in POSIX mode), we're done */ - else if(optstr[0] == '+' || getenv("POSIXLY_CORRECT")) - { - c = -1; - - /* Everything else is a non-opt argument */ - nonopt = argc - argv_index; - } - /* If we mildly don't want it, then move it back */ - else - { - if(!permute_argv_once()) goto getopt_top; - else c = -1; - } - } - /* Otherwise we're looking at an option */ - else - { - char* opt_ptr = NULL; - - /* Grab the option */ - c = argv[argv_index][opt_offset++]; - - /* Is the option in the optstr? */ - if(optstr[0] == '-') opt_ptr = strchr(optstr+1, c); - else opt_ptr = strchr(optstr, c); - /* Invalid argument */ - if(!opt_ptr) - { - if(opterr) - { - fprintf(stderr, "%s: invalid option -- %c\n", argv[0], c); - } - - optopt = c; - c = '?'; - - /* Move onto the next option */ - increment_index(); - } - /* Option takes argument */ - else if(opt_ptr[1] == ':') - { - /* ie, -oARGUMENT, -xxxoARGUMENT, etc. */ - if(argv[argv_index][opt_offset] != '\0') - { - optarg = &argv[argv_index][opt_offset]; - increment_index(); - } - /* ie, -o ARGUMENT (only if it's a required argument) */ - else if(opt_ptr[2] != ':') - { - /* One of those "you're not expected to understand this" moment */ - if(argv_index2 < argv_index) argv_index2 = argv_index; - while(argv[++argv_index2] && argv[argv_index2][0] == '-'); - optarg = argv[argv_index2]; - - /* Don't cross into the non-option argument list */ - if(argv_index2 + nonopt >= prev_argc) optarg = NULL; - - /* Move onto the next option */ - increment_index(); - } - else - { - /* Move onto the next option */ - increment_index(); - } - - /* In case we got no argument for an option with required argument */ - if(optarg == NULL && opt_ptr[2] != ':') - { - optopt = c; - c = '?'; - - if(opterr) - { - fprintf(stderr,"%s: option requires an argument -- %c\n", - argv[0], optopt); - } - } - } - /* Option does not take argument */ - else - { - /* Next argv_index */ - if(argv[argv_index][opt_offset] == '\0') - { - increment_index(); - } - } - } - - /* Calculate optind */ - if(c == -1) - { - optind = argc - nonopt; - } - else - { - optind = argv_index; - } - - return c; -} - - -/* vim:ts=3 -*/ diff --git a/tests/getopt.c b/support/getopt.c similarity index 100% rename from tests/getopt.c rename to support/getopt.c diff --git a/examples/getopt.h b/support/getopt.h similarity index 100% rename from examples/getopt.h rename to support/getopt.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 55862fac..bcad7ef5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,16 +12,19 @@ include_directories(${GLFW_SOURCE_DIR}/include ${GLFW_SOURCE_DIR}/support ${OPENGL_INCLUDE_DIR}) -add_executable(clipboard clipboard.c getopt.c) +set(GETOPT ${GLFW_SOURCE_DIR}/support/getopt.h + ${GLFW_SOURCE_DIR}/support/getopt.c) + +add_executable(clipboard clipboard.c ${GETOPT}) add_executable(defaults defaults.c) add_executable(events events.c) -add_executable(fsaa fsaa.c getopt.c) +add_executable(fsaa fsaa.c ${GETOPT}) add_executable(fsfocus fsfocus.c) -add_executable(gamma gamma.c getopt.c) -add_executable(glfwinfo glfwinfo.c getopt.c) -add_executable(iconify iconify.c getopt.c) +add_executable(gamma gamma.c ${GETOPT}) +add_executable(glfwinfo glfwinfo.c ${GETOPT}) +add_executable(iconify iconify.c ${GETOPT}) add_executable(joysticks joysticks.c) -add_executable(modes modes.c getopt.c) +add_executable(modes modes.c ${GETOPT}) add_executable(peter peter.c) add_executable(reopen reopen.c) diff --git a/tests/getopt.h b/tests/getopt.h deleted file mode 100644 index 0b78650a..00000000 --- a/tests/getopt.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************** -* getopt.h - competent and free getopt library. -* $Header: /cvsroot/freegetopt/freegetopt/getopt.h,v 1.2 2003/10/26 03:10:20 vindaci Exp $ -* -* Copyright (c)2002-2003 Mark K. Kim -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in -* the documentation and/or other materials provided with the -* distribution. -* -* * Neither the original author of this software nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS -* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF -* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -* DAMAGE. -*/ -#ifndef GETOPT_H_ -#define GETOPT_H_ - - -#ifdef __cplusplus -extern "C" { -#endif - - -extern char* optarg; -extern int optind; -extern int opterr; -extern int optopt; - -int getopt(int argc, char** argv, char* optstr); - - -#ifdef __cplusplus -} -#endif - - -#endif /* GETOPT_H_ */ - - -/* vim:ts=3 -*/ From ab373308b0b03577b003104885ac11f399bffcba Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 12:50:44 +0200 Subject: [PATCH 19/29] Removed mistaken comment. --- src/error.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/error.c b/src/error.c index c7926e9c..d64cb7cc 100644 --- a/src/error.c +++ b/src/error.c @@ -59,8 +59,6 @@ void _glfwSetError(int error, const char* format, ...) char buffer[16384]; const char* description; - // We would use vasprintf here if msvcrt supported it - if (format) { int count; From d8ccf5d2723c5d8972244373097f1559d7364ffe Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 13:36:52 +0200 Subject: [PATCH 20/29] Formatting. --- tests/tearing.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/tearing.c b/tests/tearing.c index 165ec01c..a8d774a4 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -43,9 +43,7 @@ static void set_swap_interval(GLFWwindow window, int interval) swap_interval = interval; glfwSwapInterval(swap_interval); - sprintf(title, - "Tearing detector (interval %i)", - swap_interval); + sprintf(title, "Tearing detector (interval %i)", swap_interval); glfwSetWindowTitle(window, title); } From 3162f290a6ab487209db9a83a7c2f445f812ed96 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 13:37:12 +0200 Subject: [PATCH 21/29] Fixed float constant type mismatches. --- tests/windows.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/windows.c b/tests/windows.c index 7b1a529c..894febeb 100644 --- a/tests/windows.c +++ b/tests/windows.c @@ -67,8 +67,8 @@ int main(void) glfwMakeContextCurrent(windows[i]); glClearColor((GLclampf) (i & 1), (GLclampf) (i >> 1), - i ? 0.0 : 1.0, - 0.0); + i ? 0.f : 1.f, + 0.f); glfwSetWindowPos(windows[i], 100 + (i & 1) * 300, 100 + (i >> 1) * 300); } From c2729181a2d1f3dc52e1606c8333da452ee525be Mon Sep 17 00:00:00 2001 From: Lambert Clara Date: Sun, 12 Aug 2012 13:24:21 +0200 Subject: [PATCH 22/29] Fix various warnings reported by gcc Shadowed variables, const warnings --- examples/boing.c | 6 +++--- examples/splitview.c | 1 - src/x11_joystick.c | 2 +- support/getopt.c | 7 +++++-- support/getopt.h | 2 +- tests/defaults.c | 6 +++--- tests/gamma.c | 22 +++++++++++----------- tests/iconify.c | 10 ++++------ tests/modes.c | 2 +- 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 3cc09730..a2094c5f 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -330,7 +330,7 @@ void DrawBoingBall( void ) /***************************************************************************** * Bounce the ball. *****************************************************************************/ -void BounceBall( double dt ) +void BounceBall( double delta_t ) { GLfloat sign; GLfloat deg; @@ -358,8 +358,8 @@ void BounceBall( double dt ) } /* Update ball position */ - ball_x += ball_x_inc * ((float)dt*ANIMATION_SPEED); - ball_y += ball_y_inc * ((float)dt*ANIMATION_SPEED); + ball_x += ball_x_inc * ((float)delta_t*ANIMATION_SPEED); + ball_y += ball_y_inc * ((float)delta_t*ANIMATION_SPEED); /* * Simulate the effects of gravity on Y movement. diff --git a/examples/splitview.c b/examples/splitview.c index c602d0c4..4a48a383 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -442,7 +442,6 @@ static void mouseButtonFun(GLFWwindow window, int button, int action) int main(void) { GLFWwindow window; - int width, height; // Initialise GLFW if (!glfwInit()) diff --git a/src/x11_joystick.c b/src/x11_joystick.c index 444c479f..9fc921fd 100644 --- a/src/x11_joystick.c +++ b/src/x11_joystick.c @@ -83,7 +83,7 @@ void _glfwInitJoysticks(void) { #ifdef _GLFW_USE_LINUX_JOYSTICKS int k, n, fd, joy_count; - char* joy_base_name; + const char* joy_base_name; char joy_dev_name[20]; int driver_version = 0x000800; char ret_data; diff --git a/support/getopt.c b/support/getopt.c index 712cf28a..6ff6ef99 100644 --- a/support/getopt.c +++ b/support/getopt.c @@ -41,7 +41,10 @@ #include #include "getopt.h" - +/* 2012-08-12 Lambert Clara + * + * Constify third argument of getopt. + */ /* 2011-07-27 Camilla Berglund * * Added _CRT_SECURE_NO_WARNINGS macro. @@ -102,7 +105,7 @@ static int permute_argv_once() } -int getopt(int argc, char** argv, char* optstr) +int getopt(int argc, char** argv, const char* optstr) { int c = 0; diff --git a/support/getopt.h b/support/getopt.h index 0b78650a..6d2e4afe 100644 --- a/support/getopt.h +++ b/support/getopt.h @@ -48,7 +48,7 @@ extern int optind; extern int opterr; extern int optopt; -int getopt(int argc, char** argv, char* optstr); +int getopt(int argc, char** argv, const char* optstr); #ifdef __cplusplus diff --git a/tests/defaults.c b/tests/defaults.c index 5e3f3890..63212a29 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -41,14 +41,14 @@ typedef struct { int param; - char* ext; - char* name; + const char* ext; + const char* name; } ParamGL; typedef struct { int param; - char* name; + const char* name; } ParamGLFW; static ParamGL gl_params[] = diff --git a/tests/gamma.c b/tests/gamma.c index 7d93ed06..e74d5b43 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -37,7 +37,7 @@ #define STEP_SIZE 0.1f -static GLfloat gamma = 1.0f; +static GLfloat gamma_value = 1.0f; static void usage(void) { @@ -46,9 +46,9 @@ static void usage(void) static void set_gamma(float value) { - gamma = value; - printf("Gamma: %f\n", gamma); - glfwSetGamma(gamma); + gamma_value = value; + printf("Gamma: %f\n", gamma_value); + glfwSetGamma(gamma_value); } static void key_callback(GLFWwindow window, int key, int action) @@ -67,15 +67,15 @@ static void key_callback(GLFWwindow window, int key, int action) case GLFW_KEY_KP_ADD: case GLFW_KEY_Q: { - set_gamma(gamma + STEP_SIZE); + set_gamma(gamma_value + STEP_SIZE); break; } case GLFW_KEY_KP_SUBTRACT: case GLFW_KEY_W: { - if (gamma - STEP_SIZE > 0.f) - set_gamma(gamma - STEP_SIZE); + if (gamma_value - STEP_SIZE > 0.f) + set_gamma(gamma_value - STEP_SIZE); break; } @@ -119,10 +119,10 @@ int main(int argc, char** argv) if (mode == GLFW_FULLSCREEN) { - GLFWvidmode mode; - glfwGetDesktopMode(&mode); - width = mode.width; - height = mode.height; + GLFWvidmode desktop_mode; + glfwGetDesktopMode(&desktop_mode); + width = desktop_mode.width; + height = desktop_mode.height; } else { diff --git a/tests/iconify.c b/tests/iconify.c index d1a505b5..33b6f058 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -100,10 +100,10 @@ int main(int argc, char** argv) if (mode == GLFW_FULLSCREEN) { - GLFWvidmode mode; - glfwGetDesktopMode(&mode); - width = mode.width; - height = mode.height; + GLFWvidmode desktop_mode; + glfwGetDesktopMode(&desktop_mode); + width = desktop_mode.width; + height = desktop_mode.height; } else { @@ -130,8 +130,6 @@ int main(int argc, char** argv) while (!glfwGetWindowParam(window, GLFW_CLOSE_REQUESTED)) { - int width, height; - if (iconified != glfwGetWindowParam(window, GLFW_ICONIFIED) || active != glfwGetWindowParam(window, GLFW_ACTIVE)) { diff --git a/tests/modes.c b/tests/modes.c index b5912ed7..5ce65abb 100644 --- a/tests/modes.c +++ b/tests/modes.c @@ -68,7 +68,7 @@ static void error_callback(int error, const char* description) fprintf(stderr, "Error: %s\n", description); } -static void window_size_callback(GLFWwindow window, int width, int height) +static void window_size_callback(GLFWwindow in_window, int width, int height) { printf("Window resized to %ix%i\n", width, height); From 25c7ad170680e308161fb687ee344d42c37dca02 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 14:14:03 +0200 Subject: [PATCH 23/29] Removed superfluous MakeContextCurrent. --- src/cocoa_window.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 446d718e..8cf749a5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -927,8 +927,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, withOptions:nil]; } - glfwMakeContextCurrent(window); - NSPoint point = [[NSCursor currentCursor] hotSpot]; window->cursorPosX = point.x; window->cursorPosY = point.y; From cb447bee81ad3a7e7e3046cadd05ccce348643f6 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 14:15:39 +0200 Subject: [PATCH 24/29] Cleanup of window resizable flag setting. --- src/cocoa_window.m | 4 ---- src/win32_window.c | 1 - src/window.c | 1 + src/x11_window.c | 1 - 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 8cf749a5..d7764f92 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -866,8 +866,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, if (!initializeAppKit()) return GL_FALSE; - window->resizable = wndconfig->resizable; - // We can only have one application delegate, but we only allocate it the // first time we create a window to keep all window code in this file if (_glfwLibrary.NS.delegate == nil) @@ -931,8 +929,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, window->cursorPosX = point.x; window->cursorPosY = point.y; - window->resizable = wndconfig->resizable; - return GL_TRUE; } diff --git a/src/win32_window.c b/src/win32_window.c index 00fb269d..65122eef 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -959,7 +959,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, GLboolean recreateContext = GL_FALSE; window->Win32.desiredRefreshRate = wndconfig->refreshRate; - window->resizable = wndconfig->resizable; if (!_glfwLibrary.Win32.classAtom) { diff --git a/src/window.c b/src/window.c index df592751..8da2f580 100644 --- a/src/window.c +++ b/src/window.c @@ -300,6 +300,7 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height, window->width = width; window->height = height; window->mode = mode; + window->resizable = wndconfig.resizable; window->cursorMode = GLFW_CURSOR_NORMAL; window->systemKeys = GL_TRUE; diff --git a/src/x11_window.c b/src/x11_window.c index 05d1be83..442e76c0 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -889,7 +889,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWfbconfig* fbconfig) { window->refreshRate = wndconfig->refreshRate; - window->resizable = wndconfig->resizable; if (!_glfwCreateContext(window, wndconfig, fbconfig)) return GL_FALSE; From 7bdadcb671e1cab0c37b2e36159c3c4780497aac Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 15:31:15 +0200 Subject: [PATCH 25/29] Replaced inline defines with glext. --- tests/defaults.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/defaults.c b/tests/defaults.c index 5e3f3890..8ab490d3 100644 --- a/tests/defaults.c +++ b/tests/defaults.c @@ -30,14 +30,11 @@ //======================================================================== #include +#include #include #include -#ifndef GL_ARB_multisample - #define GL_SAMPLES_ARB 0x80A9 -#endif - typedef struct { int param; From 06b5d0f66505259663099ba025bf131ce9d04c71 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 15:32:06 +0200 Subject: [PATCH 26/29] Formatting. --- tests/accuracy.c | 4 +--- tests/tearing.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/accuracy.c b/tests/accuracy.c index c9a82ec7..f3fb752b 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -46,9 +46,7 @@ static void set_swap_interval(GLFWwindow window, int interval) swap_interval = interval; glfwSwapInterval(swap_interval); - sprintf(title, - "Cursor Inaccuracy Detector (interval %i)", - swap_interval); + sprintf(title, "Cursor Inaccuracy Detector (interval %i)", swap_interval); glfwSetWindowTitle(window, title); } diff --git a/tests/tearing.c b/tests/tearing.c index 165ec01c..a8d774a4 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -43,9 +43,7 @@ static void set_swap_interval(GLFWwindow window, int interval) swap_interval = interval; glfwSwapInterval(swap_interval); - sprintf(title, - "Tearing detector (interval %i)", - swap_interval); + sprintf(title, "Tearing detector (interval %i)", swap_interval); glfwSetWindowTitle(window, title); } From 5ce704e60c882a4f4f220865e79c11361c746e1f Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 16:46:29 +0200 Subject: [PATCH 27/29] Added missing include. --- src/win32_opengl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/win32_opengl.c b/src/win32_opengl.c index fe1898e7..345b7289 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -30,6 +30,8 @@ #include "internal.h" +#include + //======================================================================== // Initialize WGL-specific extensions From b7be8d90d833e18eabc7ddc01690978f156afade Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 12 Aug 2012 22:31:47 +0200 Subject: [PATCH 28/29] Renamed libglfw3.pc to glfw3.pc. --- CMakeLists.txt | 6 +++--- src/{libglfw3.pc.in => glfw3.pc.in} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename src/{libglfw3.pc.in => glfw3.pc.in} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a609a6..cd712c46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -262,10 +262,10 @@ install(FILES COPYING.txt readme.html # Create and install pkg-config file on supported platforms #-------------------------------------------------------------------- if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL) - configure_file(${GLFW_SOURCE_DIR}/src/libglfw3.pc.in - ${GLFW_BINARY_DIR}/src/libglfw3.pc @ONLY) + configure_file(${GLFW_SOURCE_DIR}/src/glfw3.pc.in + ${GLFW_BINARY_DIR}/src/glfw3.pc @ONLY) - install(FILES ${GLFW_BINARY_DIR}/src/libglfw3.pc + install(FILES ${GLFW_BINARY_DIR}/src/glfw3.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) endif() diff --git a/src/libglfw3.pc.in b/src/glfw3.pc.in similarity index 100% rename from src/libglfw3.pc.in rename to src/glfw3.pc.in From 6399fb19fd91b809217a5602083e858479b1067a Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Tue, 14 Aug 2012 13:51:39 +0200 Subject: [PATCH 29/29] Included malloc.h from files using malloc on Win32. --- src/fullscreen.c | 1 + src/win32_clipboard.c | 1 + src/win32_fullscreen.c | 1 + src/win32_init.c | 1 + src/win32_opengl.c | 1 + src/win32_window.c | 1 + src/window.c | 1 + 7 files changed, 7 insertions(+) diff --git a/src/fullscreen.c b/src/fullscreen.c index d613ab7e..9dab1a59 100644 --- a/src/fullscreen.c +++ b/src/fullscreen.c @@ -31,6 +31,7 @@ #include "internal.h" #include +#include //======================================================================== diff --git a/src/win32_clipboard.c b/src/win32_clipboard.c index 2b8742ce..ca31964d 100644 --- a/src/win32_clipboard.c +++ b/src/win32_clipboard.c @@ -32,6 +32,7 @@ #include #include #include +#include ////////////////////////////////////////////////////////////////////////// diff --git a/src/win32_fullscreen.c b/src/win32_fullscreen.c index c04e5ff1..3e28e30e 100644 --- a/src/win32_fullscreen.c +++ b/src/win32_fullscreen.c @@ -32,6 +32,7 @@ #include #include +#include //======================================================================== diff --git a/src/win32_init.c b/src/win32_init.c index 5bcbb310..41444b97 100644 --- a/src/win32_init.c +++ b/src/win32_init.c @@ -31,6 +31,7 @@ #include "internal.h" #include +#include #ifdef __BORLANDC__ // With the Borland C++ compiler, we want to disable FPU exceptions diff --git a/src/win32_opengl.c b/src/win32_opengl.c index 345b7289..2c676c91 100644 --- a/src/win32_opengl.c +++ b/src/win32_opengl.c @@ -31,6 +31,7 @@ #include "internal.h" #include +#include //======================================================================== diff --git a/src/win32_window.c b/src/win32_window.c index 65122eef..77b99026 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -32,6 +32,7 @@ #include #include +#include //======================================================================== diff --git a/src/window.c b/src/window.c index 8da2f580..1e169743 100644 --- a/src/window.c +++ b/src/window.c @@ -32,6 +32,7 @@ #include #include +#include //========================================================================