From 4044c2da66c5183e6ef224d5d51610adfeed0a0d Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 24 Oct 2010 18:28:55 +0200 Subject: [PATCH] Made callbacks library global. --- examples/boing.c | 2 +- examples/gears.c | 4 +-- examples/heightmap.c | 4 +-- examples/splitview.c | 8 +++--- examples/wave.c | 4 +-- include/GL/glfw3.h | 20 +++++++-------- src/cocoa/cocoa_window.m | 16 ++++++------ src/enable.c | 8 +++--- src/input.c | 32 +++++++++++------------ src/internal.h | 23 ++++++++--------- src/win32/win32_window.c | 22 ++++++++-------- src/window.c | 55 ++++++++++++++++++++++------------------ src/x11/x11_window.c | 28 ++++++++++---------- tests/accuracy.c | 4 +-- tests/events.c | 20 +++++++-------- tests/fsaa.c | 2 +- tests/fsfocus.c | 6 ++--- tests/gamma.c | 4 +-- tests/iconify.c | 4 +-- tests/peter.c | 6 ++--- tests/reopen.c | 6 ++--- tests/sharing.c | 2 +- tests/tearing.c | 2 +- 23 files changed, 143 insertions(+), 139 deletions(-) diff --git a/examples/boing.c b/examples/boing.c index 007f3f0f..b90f3732 100644 --- a/examples/boing.c +++ b/examples/boing.c @@ -585,7 +585,7 @@ int main( void ) exit( EXIT_FAILURE ); } - glfwSetWindowSizeCallback( window, reshape ); + glfwSetWindowSizeCallback( reshape ); glfwEnable( window, GLFW_STICKY_KEYS ); glfwSwapInterval( 1 ); glfwSetTime( 0.0 ); diff --git a/examples/gears.c b/examples/gears.c index 1c2b209c..7271cf64 100644 --- a/examples/gears.c +++ b/examples/gears.c @@ -346,8 +346,8 @@ int main(int argc, char *argv[]) init(argc, argv); // Set callback functions - glfwSetWindowSizeCallback( window, reshape ); - glfwSetKeyCallback( window, key ); + glfwSetWindowSizeCallback( reshape ); + glfwSetKeyCallback( key ); // Main loop while( running ) diff --git a/examples/heightmap.c b/examples/heightmap.c index b5f2fdbc..4f8c1c0a 100644 --- a/examples/heightmap.c +++ b/examples/heightmap.c @@ -597,8 +597,8 @@ int main(int argc, char** argv) free(fragment_shader_src); exit(EXIT_FAILURE); } - glfwSetWindowCloseCallback(window, window_close_callback); - glfwSetKeyCallback(window, key_callback); + glfwSetWindowCloseCallback(window_close_callback); + glfwSetKeyCallback(key_callback); /* Register events callback */ if (GL_TRUE != init_opengl()) diff --git a/examples/splitview.c b/examples/splitview.c index 42c5ec16..d05b078c 100644 --- a/examples/splitview.c +++ b/examples/splitview.c @@ -468,10 +468,10 @@ int main(void) glfwEnable(window, GLFW_MOUSE_CURSOR); // Set callback functions - glfwSetWindowSizeCallback(window, windowSizeFun); - glfwSetWindowRefreshCallback(window, windowRefreshFun); - glfwSetMousePosCallback(window, mousePosFun); - glfwSetMouseButtonCallback(window, mouseButtonFun); + glfwSetWindowSizeCallback(windowSizeFun); + glfwSetWindowRefreshCallback(windowRefreshFun); + glfwSetMousePosCallback(mousePosFun); + glfwSetMouseButtonCallback(mouseButtonFun); // Main loop do diff --git a/examples/wave.c b/examples/wave.c index f38a1ee4..49bf1a68 100644 --- a/examples/wave.c +++ b/examples/wave.c @@ -339,11 +339,11 @@ int main(int argc, char* argv[]) glfwSwapInterval(1); // Keyboard handler - glfwSetKeyCallback(window, key_callback); + glfwSetKeyCallback(key_callback); glfwEnable(window, GLFW_KEY_REPEAT); // Window resize handler - glfwSetWindowSizeCallback(window, window_resize_callback); + glfwSetWindowSizeCallback(window_resize_callback); // Initialize OpenGL init_opengl(); diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 08e0d006..e2316413 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -442,11 +442,11 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow window); GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param); GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer); GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window); -GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun); -GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun); -GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun); -GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun); -GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun); +GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun); +GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun); +GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun); +GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun); +GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun); /* Event handling */ GLFWAPI void glfwPollEvents(void); @@ -458,11 +458,11 @@ GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button); GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos); GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos); GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y); -GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun); -GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun); -GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun); -GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun); -GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun); +GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); +GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); +GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun); +GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun); +GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun); /* Joystick input */ GLFWAPI int glfwGetJoystickParam(int joy, int param); diff --git a/src/cocoa/cocoa_window.m b/src/cocoa/cocoa_window.m index eeb1a13a..2b389e4d 100644 --- a/src/cocoa/cocoa_window.m +++ b/src/cocoa/cocoa_window.m @@ -70,8 +70,8 @@ window->width = contentRect.size.width; window->height = contentRect.size.height; - if (window->windowSizeCallback) - window->windowSizeCallback(window, window->width, window->height); + if (_glfwLibrary.windowSizeCallback) + _glfwLibrary.windowSizeCallback(window, window->width, window->height); } - (void)windowDidMove:(NSNotification *)notification @@ -95,16 +95,16 @@ { window->iconified = GL_TRUE; - if (window->windowIconifyCallback) - window->windowIconifyCallback(window, window->iconified); + if (_glfwLibrary.windowIconifyCallback) + _glfwLibrary.windowIconifyCallback(window, window->iconified); } - (void)windowDidDeminiaturize:(NSNotification *)notification { window->iconified = GL_FALSE; - if (window->windowIconifyCallback) - window->windowIconifyCallback(window, window->iconified); + if (_glfwLibrary.windowIconifyCallback) + _glfwLibrary.windowIconifyCallback(window, window->iconified); } - (void)windowDidBecomeKey:(NSNotification *)notification @@ -362,8 +362,8 @@ static int convertMacKeyCode(unsigned int macKeyCode) window->mousePosY = [[window->NS.window contentView] bounds].size.height - p.y; } - if (window->mousePosCallback) - window->mousePosCallback(window, window->mousePosX, window->mousePosY); + if (_glfwLibrary.mousePosCallback) + _glfwLibrary.mousePosCallback(window, window->mousePosX, window->mousePosY); } - (void)rightMouseDown:(NSEvent *)event diff --git a/src/enable.c b/src/enable.c index 7a8534a1..60789290 100644 --- a/src/enable.c +++ b/src/enable.c @@ -54,11 +54,11 @@ static void enableMouseCursor(_GLFWwindow* window) window->mousePosX = centerPosX; window->mousePosY = centerPosY; - if (window->mousePosCallback) + if (_glfwLibrary.mousePosCallback) { - window->mousePosCallback(window, - window->mousePosX, - window->mousePosY); + _glfwLibrary.mousePosCallback(window, + window->mousePosX, + window->mousePosY); } } diff --git a/src/input.c b/src/input.c index c5ad0c7b..8a61fbef 100644 --- a/src/input.c +++ b/src/input.c @@ -171,7 +171,7 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y) // Set callback function for keyboard input //======================================================================== -GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun) +GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun) { if (!_glfwInitialized) { @@ -179,7 +179,7 @@ GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun) return; } - window->keyCallback = cbfun; + _glfwLibrary.keyCallback = cbfun; } @@ -187,7 +187,7 @@ GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun) // Set callback function for character input //======================================================================== -GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun) +GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun) { if (!_glfwInitialized) { @@ -195,7 +195,7 @@ GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun) return; } - window->charCallback = cbfun; + _glfwLibrary.charCallback = cbfun; } @@ -203,7 +203,7 @@ GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun) // Set callback function for mouse clicks //======================================================================== -GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun) +GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun) { if (!_glfwInitialized) { @@ -211,7 +211,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cb return; } - window->mouseButtonCallback = cbfun; + _glfwLibrary.mouseButtonCallback = cbfun; } @@ -219,7 +219,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cb // Set callback function for mouse moves //======================================================================== -GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun) +GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun) { if (!_glfwInitialized) { @@ -228,12 +228,17 @@ GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun) } // Set callback function - window->mousePosCallback = cbfun; + _glfwLibrary.mousePosCallback = cbfun; // Call the callback function to let the application know the current // mouse position if (cbfun) - cbfun(window, window->mousePosX, window->mousePosY); + { + _GLFWwindow* window; + + for (window = _glfwLibrary.windowListHead; window; window = window->next) + cbfun(window, window->mousePosX, window->mousePosY); + } } @@ -241,7 +246,7 @@ GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun) // Set callback function for scroll events //======================================================================== -GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun) +GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun) { if (!_glfwInitialized) { @@ -250,11 +255,6 @@ GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun) } // Set callback function - window->scrollCallback = cbfun; - - // Call the callback function to let the application know the current - // scroll offset - if (cbfun) - cbfun(window, window->scrollX, window->scrollY); + _glfwLibrary.scrollCallback = cbfun; } diff --git a/src/internal.h b/src/internal.h index a44ab51a..b064ebb5 100644 --- a/src/internal.h +++ b/src/internal.h @@ -152,18 +152,6 @@ struct _GLFWwindow { struct _GLFWwindow* next; - // User callback functions - GLFWwindowsizefun windowSizeCallback; - GLFWwindowclosefun windowCloseCallback; - GLFWwindowrefreshfun windowRefreshCallback; - GLFWwindowfocusfun windowFocusCallback; - GLFWwindowiconifyfun windowIconifyCallback; - GLFWmousebuttonfun mouseButtonCallback; - GLFWmouseposfun mousePosCallback; - GLFWscrollfun scrollCallback; - GLFWkeyfun keyCallback; - GLFWcharfun charCallback; - // Window settings and state GLboolean iconified; // GL_TRUE if this window is iconified GLboolean closeRequested; // GL_TRUE if this window should be closed @@ -223,6 +211,17 @@ struct _GLFWlibrary _GLFWwindow* activeWindow; _GLFWwindow* cursorLockWindow; + GLFWwindowsizefun windowSizeCallback; + GLFWwindowclosefun windowCloseCallback; + GLFWwindowrefreshfun windowRefreshCallback; + GLFWwindowfocusfun windowFocusCallback; + GLFWwindowiconifyfun windowIconifyCallback; + GLFWmousebuttonfun mouseButtonCallback; + GLFWmouseposfun mousePosCallback; + GLFWscrollfun scrollCallback; + GLFWkeyfun keyCallback; + GLFWcharfun charCallback; + GLFWgammaramp currentRamp; GLFWgammaramp originalRamp; int originalRampSize; diff --git a/src/win32/win32_window.c b/src/win32/win32_window.c index 059faa4b..07ae49d1 100644 --- a/src/win32/win32_window.c +++ b/src/win32/win32_window.c @@ -713,8 +713,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, { window->iconified = iconified; - if (window->windowIconifyCallback) - window->windowIconifyCallback(window, window->iconified); + if (_glfwLibrary.windowIconifyCallback) + _glfwLibrary.windowIconifyCallback(window, window->iconified); } return 0; @@ -756,7 +756,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, { _glfwInputKey(window, translateKey(wParam, lParam), GLFW_PRESS); - if (window->charCallback) + if (_glfwLibrary.charCallback) translateChar(window, (DWORD) wParam, (DWORD) lParam); return 0; @@ -879,11 +879,11 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, window->Win32.oldMouseY = newMouseY; window->Win32.mouseMoved = GL_TRUE; - if (window->mousePosCallback) + if (_glfwLibrary.mousePosCallback) { - window->mousePosCallback(window, - window->mousePosX, - window->mousePosY); + _glfwLibrary.mousePosCallback(window, + window->mousePosX, + window->mousePosY); } } @@ -917,8 +917,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, ClipCursor(&ClipWindowRect); } - if (window->windowSizeCallback) - window->windowSizeCallback(window, window->width, window->height); + if (_glfwLibrary.windowSizeCallback) + _glfwLibrary.windowSizeCallback(window, window->width, window->height); return 0; } @@ -941,8 +941,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, // Was the window contents damaged? case WM_PAINT: { - if (window->windowRefreshCallback) - window->windowRefreshCallback(window); + if (_glfwLibrary.windowRefreshCallback) + _glfwLibrary.windowRefreshCallback(window); break; } diff --git a/src/window.c b/src/window.c index 14b0c4dc..8b4a7903 100644 --- a/src/window.c +++ b/src/window.c @@ -55,8 +55,8 @@ static void closeFlaggedWindows(void) for (window = _glfwLibrary.windowListHead; window; ) { - if (window->closeRequested && window->windowCloseCallback) - window->closeRequested = window->windowCloseCallback(window); + if (window->closeRequested && _glfwLibrary.windowCloseCallback) + window->closeRequested = _glfwLibrary.windowCloseCallback(window); if (window->closeRequested) { @@ -144,8 +144,8 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action) } // Call user callback function - if (window->keyCallback && (window->keyRepeat || !keyrepeat)) - window->keyCallback(window, key, action); + if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat)) + _glfwLibrary.keyCallback(window, key, action); } @@ -159,8 +159,8 @@ void _glfwInputChar(_GLFWwindow* window, int character) if (!((character >= 32 && character <= 126) || character >= 160)) return; - if (window->charCallback) - window->charCallback(window, character); + if (_glfwLibrary.charCallback) + _glfwLibrary.charCallback(window, character); } @@ -173,8 +173,8 @@ void _glfwInputScroll(_GLFWwindow* window, int x, int y) window->scrollX += x; window->scrollY += y; - if (window->scrollCallback) - window->scrollCallback(window, x, y); + if (_glfwLibrary.scrollCallback) + _glfwLibrary.scrollCallback(window, x, y); } @@ -193,8 +193,8 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action) else window->mouseButton[button] = (char) action; - if (window->mouseButtonCallback) - window->mouseButtonCallback(window, button, action); + if (_glfwLibrary.mouseButtonCallback) + _glfwLibrary.mouseButtonCallback(window, button, action); } @@ -210,8 +210,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated) { _glfwLibrary.activeWindow = window; - if (window->windowFocusCallback) - window->windowFocusCallback(window, activated); + if (_glfwLibrary.windowFocusCallback) + _glfwLibrary.windowFocusCallback(window, activated); } } else @@ -236,8 +236,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated) _glfwLibrary.activeWindow = NULL; - if (window->windowFocusCallback) - window->windowFocusCallback(window, activated); + if (_glfwLibrary.windowFocusCallback) + _glfwLibrary.windowFocusCallback(window, activated); } } } @@ -1076,7 +1076,7 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window) // Set callback function for window size changes //======================================================================== -GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun) +GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun) { if (!_glfwInitialized) { @@ -1084,19 +1084,24 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfu return; } - window->windowSizeCallback = cbfun; + _glfwLibrary.windowSizeCallback = cbfun; // Call the callback function to let the application know the current // window size if (cbfun) - cbfun(window, window->width, window->height); + { + _GLFWwindow* window; + + for (window = _glfwLibrary.windowListHead; window; window = window->next) + cbfun(window, window->width, window->height); + } } //======================================================================== // Set callback function for window close events //======================================================================== -GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun) +GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun) { if (!_glfwInitialized) { @@ -1104,7 +1109,7 @@ GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cb return; } - window->windowCloseCallback = cbfun; + _glfwLibrary.windowCloseCallback = cbfun; } @@ -1112,7 +1117,7 @@ GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cb // Set callback function for window refresh events //======================================================================== -GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun) +GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun) { if (!_glfwInitialized) { @@ -1120,7 +1125,7 @@ GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfu return; } - window->windowRefreshCallback = cbfun; + _glfwLibrary.windowRefreshCallback = cbfun; } @@ -1128,7 +1133,7 @@ GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfu // Set callback function for window focus events //======================================================================== -GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun) +GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun) { if (!_glfwInitialized) { @@ -1136,7 +1141,7 @@ GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cb return; } - window->windowFocusCallback = cbfun; + _glfwLibrary.windowFocusCallback = cbfun; } @@ -1144,7 +1149,7 @@ GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cb // Set callback function for window iconification events //======================================================================== -GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun) +GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun) { if (!_glfwInitialized) { @@ -1152,7 +1157,7 @@ GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfu return; } - window->windowIconifyCallback = cbfun; + _glfwLibrary.windowIconifyCallback = cbfun; } diff --git a/src/x11/x11_window.c b/src/x11/x11_window.c index e83c8cbc..4b67bb41 100644 --- a/src/x11/x11_window.c +++ b/src/x11/x11_window.c @@ -1197,11 +1197,11 @@ static void processSingleEvent(void) window->X11.cursorPosY = event.xmotion.y; window->X11.mouseMoved = GL_TRUE; - if (window->mousePosCallback) + if (_glfwLibrary.mousePosCallback) { - window->mousePosCallback(window, - window->mousePosX, - window->mousePosY); + _glfwLibrary.mousePosCallback(window, + window->mousePosX, + window->mousePosY); } } break; @@ -1224,11 +1224,11 @@ static void processSingleEvent(void) window->width = event.xconfigure.width; window->height = event.xconfigure.height; - if (window->windowSizeCallback) + if (_glfwLibrary.windowSizeCallback) { - window->windowSizeCallback(window, - window->width, - window->height); + _glfwLibrary.windowSizeCallback(window, + window->width, + window->height); } } @@ -1288,8 +1288,8 @@ static void processSingleEvent(void) window->iconified = GL_FALSE; - if (window->windowIconifyCallback) - window->windowIconifyCallback(window, window->iconified); + if (_glfwLibrary.windowIconifyCallback) + _glfwLibrary.windowIconifyCallback(window, window->iconified); break; } @@ -1306,8 +1306,8 @@ static void processSingleEvent(void) window->iconified = GL_TRUE; - if (window->windowIconifyCallback) - window->windowIconifyCallback(window, window->iconified); + if (_glfwLibrary.windowIconifyCallback) + _glfwLibrary.windowIconifyCallback(window, window->iconified); break; } @@ -1358,8 +1358,8 @@ static void processSingleEvent(void) return; } - if (window->windowRefreshCallback) - window->windowRefreshCallback(window); + if (_glfwLibrary.windowRefreshCallback) + _glfwLibrary.windowRefreshCallback(window); break; } diff --git a/tests/accuracy.c b/tests/accuracy.c index 08fdabe0..c3bebaca 100644 --- a/tests/accuracy.c +++ b/tests/accuracy.c @@ -74,8 +74,8 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetMousePosCallback(window, mouse_position_callback); - glfwSetWindowSizeCallback(window, window_size_callback); + glfwSetMousePosCallback(mouse_position_callback); + glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); glClearColor(0, 0, 0, 0); diff --git a/tests/events.c b/tests/events.c index 8da2b983..e6fda25e 100644 --- a/tests/events.c +++ b/tests/events.c @@ -303,16 +303,16 @@ int main(void) glfwSwapInterval(1); - glfwSetWindowSizeCallback(window, window_size_callback); - glfwSetWindowCloseCallback(window, window_close_callback); - glfwSetWindowRefreshCallback(window, window_refresh_callback); - glfwSetWindowFocusCallback(window, window_focus_callback); - glfwSetWindowIconifyCallback(window, window_iconify_callback); - glfwSetMouseButtonCallback(window, mouse_button_callback); - glfwSetMousePosCallback(window, mouse_position_callback); - glfwSetScrollCallback(window, scroll_callback); - glfwSetKeyCallback(window, key_callback); - glfwSetCharCallback(window, char_callback); + glfwSetWindowSizeCallback(window_size_callback); + glfwSetWindowCloseCallback(window_close_callback); + glfwSetWindowRefreshCallback(window_refresh_callback); + glfwSetWindowFocusCallback(window_focus_callback); + glfwSetWindowIconifyCallback(window_iconify_callback); + glfwSetMouseButtonCallback(mouse_button_callback); + glfwSetMousePosCallback(mouse_position_callback); + glfwSetScrollCallback(scroll_callback); + glfwSetKeyCallback(key_callback); + glfwSetCharCallback(char_callback); printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled"); printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled"); diff --git a/tests/fsaa.c b/tests/fsaa.c index 4c834aea..e5a187a0 100644 --- a/tests/fsaa.c +++ b/tests/fsaa.c @@ -65,7 +65,7 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetWindowSizeCallback(window, window_size_callback); + glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); samples = glfwGetWindowParam(window, GLFW_FSAA_SAMPLES); diff --git a/tests/fsfocus.c b/tests/fsfocus.c index a1cefc7d..21631f25 100644 --- a/tests/fsfocus.c +++ b/tests/fsfocus.c @@ -93,9 +93,9 @@ int main(void) glfwSwapInterval(1); glfwEnable(window, GLFW_MOUSE_CURSOR); - glfwSetWindowFocusCallback(window, window_focus_callback); - glfwSetKeyCallback(window, window_key_callback); - glfwSetWindowCloseCallback(window, window_close_callback); + glfwSetWindowFocusCallback(window_focus_callback); + glfwSetKeyCallback(window_key_callback); + glfwSetWindowCloseCallback(window_close_callback); while (running && glfwIsWindow(window) == GL_TRUE) { diff --git a/tests/gamma.c b/tests/gamma.c index e918a156..0d2ff09b 100644 --- a/tests/gamma.c +++ b/tests/gamma.c @@ -149,8 +149,8 @@ int main(int argc, char** argv) ggamma, ggain, gblacklevel); glfwSwapInterval(1); - glfwSetKeyCallback(window, key_callback); - glfwSetWindowSizeCallback(window, size_callback); + glfwSetKeyCallback(key_callback); + glfwSetWindowSizeCallback(size_callback); glEnable(GL_SCISSOR_TEST); diff --git a/tests/iconify.c b/tests/iconify.c index b870bf95..6868c9ad 100644 --- a/tests/iconify.c +++ b/tests/iconify.c @@ -119,8 +119,8 @@ int main(int argc, char** argv) } glfwSwapInterval(1); - glfwSetKeyCallback(window, key_callback); - glfwSetWindowSizeCallback(window, size_callback); + glfwSetKeyCallback(key_callback); + glfwSetWindowSizeCallback(size_callback); glEnable(GL_SCISSOR_TEST); diff --git a/tests/peter.c b/tests/peter.c index 95ab744f..e2671248 100644 --- a/tests/peter.c +++ b/tests/peter.c @@ -96,9 +96,9 @@ static GLboolean open_window(void) glfwGetMousePos(window_handle, &x, &y); printf("Mouse position: %i %i\n", x, y); - glfwSetWindowSizeCallback(window_handle, window_size_callback); - glfwSetMousePosCallback(window_handle, mouse_position_callback); - glfwSetKeyCallback(window_handle, key_callback); + glfwSetWindowSizeCallback(window_size_callback); + glfwSetMousePosCallback(mouse_position_callback); + glfwSetKeyCallback(key_callback); glfwSwapInterval(1); return GL_TRUE; diff --git a/tests/reopen.c b/tests/reopen.c index 6f464af2..76f914ae 100644 --- a/tests/reopen.c +++ b/tests/reopen.c @@ -91,9 +91,9 @@ static int open_window(int width, int height, int mode) return 0; } - glfwSetWindowSizeCallback(window_handle, window_size_callback); - glfwSetWindowCloseCallback(window_handle, window_close_callback); - glfwSetKeyCallback(window_handle, key_callback); + glfwSetWindowSizeCallback(window_size_callback); + glfwSetWindowCloseCallback(window_close_callback); + glfwSetKeyCallback(key_callback); glfwSwapInterval(1); printf("Opening %s mode window took %0.3f seconds\n", diff --git a/tests/sharing.c b/tests/sharing.c index 588e5f0b..b1b335c9 100644 --- a/tests/sharing.c +++ b/tests/sharing.c @@ -49,7 +49,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share) if (!window) return NULL; - glfwSetKeyCallback(window, key_callback); + glfwSetKeyCallback(key_callback); glfwSwapInterval(1); return window; diff --git a/tests/tearing.c b/tests/tearing.c index cd493d53..6e43e88f 100644 --- a/tests/tearing.c +++ b/tests/tearing.c @@ -59,7 +59,7 @@ int main(void) exit(EXIT_FAILURE); } - glfwSetWindowSizeCallback(window, window_size_callback); + glfwSetWindowSizeCallback(window_size_callback); glfwSwapInterval(1); glClearColor(0.f, 0.f, 0.f, 0.f);