Made callbacks library global.

This commit is contained in:
Camilla Berglund 2010-10-24 18:28:55 +02:00
parent c5892fee53
commit 4044c2da66
23 changed files with 143 additions and 139 deletions

View File

@ -585,7 +585,7 @@ int main( void )
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
glfwSetWindowSizeCallback( window, reshape ); glfwSetWindowSizeCallback( reshape );
glfwEnable( window, GLFW_STICKY_KEYS ); glfwEnable( window, GLFW_STICKY_KEYS );
glfwSwapInterval( 1 ); glfwSwapInterval( 1 );
glfwSetTime( 0.0 ); glfwSetTime( 0.0 );

View File

@ -346,8 +346,8 @@ int main(int argc, char *argv[])
init(argc, argv); init(argc, argv);
// Set callback functions // Set callback functions
glfwSetWindowSizeCallback( window, reshape ); glfwSetWindowSizeCallback( reshape );
glfwSetKeyCallback( window, key ); glfwSetKeyCallback( key );
// Main loop // Main loop
while( running ) while( running )

View File

@ -597,8 +597,8 @@ int main(int argc, char** argv)
free(fragment_shader_src); free(fragment_shader_src);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowCloseCallback(window_close_callback);
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
/* Register events callback */ /* Register events callback */
if (GL_TRUE != init_opengl()) if (GL_TRUE != init_opengl())

View File

@ -468,10 +468,10 @@ int main(void)
glfwEnable(window, GLFW_MOUSE_CURSOR); glfwEnable(window, GLFW_MOUSE_CURSOR);
// Set callback functions // Set callback functions
glfwSetWindowSizeCallback(window, windowSizeFun); glfwSetWindowSizeCallback(windowSizeFun);
glfwSetWindowRefreshCallback(window, windowRefreshFun); glfwSetWindowRefreshCallback(windowRefreshFun);
glfwSetMousePosCallback(window, mousePosFun); glfwSetMousePosCallback(mousePosFun);
glfwSetMouseButtonCallback(window, mouseButtonFun); glfwSetMouseButtonCallback(mouseButtonFun);
// Main loop // Main loop
do do

View File

@ -339,11 +339,11 @@ int main(int argc, char* argv[])
glfwSwapInterval(1); glfwSwapInterval(1);
// Keyboard handler // Keyboard handler
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
glfwEnable(window, GLFW_KEY_REPEAT); glfwEnable(window, GLFW_KEY_REPEAT);
// Window resize handler // Window resize handler
glfwSetWindowSizeCallback(window, window_resize_callback); glfwSetWindowSizeCallback(window_resize_callback);
// Initialize OpenGL // Initialize OpenGL
init_opengl(); init_opengl();

View File

@ -442,11 +442,11 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow window);
GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param); GLFWAPI int glfwGetWindowParam(GLFWwindow window, int param);
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer); GLFWAPI void glfwSetWindowUserPointer(GLFWwindow window, void* pointer);
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window); GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window);
GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun); GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun);
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun); GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun);
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun); GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun);
GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun); GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun);
GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun); GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun);
/* Event handling */ /* Event handling */
GLFWAPI void glfwPollEvents(void); 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 glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos);
GLFWAPI void glfwSetMousePos(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 glfwGetScrollOffset(GLFWwindow window, int* x, int* y);
GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun); GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun);
GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun); GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun);
GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun); GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun);
GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun); GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun);
GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun); GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun);
/* Joystick input */ /* Joystick input */
GLFWAPI int glfwGetJoystickParam(int joy, int param); GLFWAPI int glfwGetJoystickParam(int joy, int param);

View File

@ -70,8 +70,8 @@
window->width = contentRect.size.width; window->width = contentRect.size.width;
window->height = contentRect.size.height; window->height = contentRect.size.height;
if (window->windowSizeCallback) if (_glfwLibrary.windowSizeCallback)
window->windowSizeCallback(window, window->width, window->height); _glfwLibrary.windowSizeCallback(window, window->width, window->height);
} }
- (void)windowDidMove:(NSNotification *)notification - (void)windowDidMove:(NSNotification *)notification
@ -95,16 +95,16 @@
{ {
window->iconified = GL_TRUE; window->iconified = GL_TRUE;
if (window->windowIconifyCallback) if (_glfwLibrary.windowIconifyCallback)
window->windowIconifyCallback(window, window->iconified); _glfwLibrary.windowIconifyCallback(window, window->iconified);
} }
- (void)windowDidDeminiaturize:(NSNotification *)notification - (void)windowDidDeminiaturize:(NSNotification *)notification
{ {
window->iconified = GL_FALSE; window->iconified = GL_FALSE;
if (window->windowIconifyCallback) if (_glfwLibrary.windowIconifyCallback)
window->windowIconifyCallback(window, window->iconified); _glfwLibrary.windowIconifyCallback(window, window->iconified);
} }
- (void)windowDidBecomeKey:(NSNotification *)notification - (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; window->mousePosY = [[window->NS.window contentView] bounds].size.height - p.y;
} }
if (window->mousePosCallback) if (_glfwLibrary.mousePosCallback)
window->mousePosCallback(window, window->mousePosX, window->mousePosY); _glfwLibrary.mousePosCallback(window, window->mousePosX, window->mousePosY);
} }
- (void)rightMouseDown:(NSEvent *)event - (void)rightMouseDown:(NSEvent *)event

View File

@ -54,9 +54,9 @@ static void enableMouseCursor(_GLFWwindow* window)
window->mousePosX = centerPosX; window->mousePosX = centerPosX;
window->mousePosY = centerPosY; window->mousePosY = centerPosY;
if (window->mousePosCallback) if (_glfwLibrary.mousePosCallback)
{ {
window->mousePosCallback(window, _glfwLibrary.mousePosCallback(window,
window->mousePosX, window->mousePosX,
window->mousePosY); window->mousePosY);
} }

View File

@ -171,7 +171,7 @@ GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* x, int* y)
// Set callback function for keyboard input // Set callback function for keyboard input
//======================================================================== //========================================================================
GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun) GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -179,7 +179,7 @@ GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun)
return; return;
} }
window->keyCallback = cbfun; _glfwLibrary.keyCallback = cbfun;
} }
@ -187,7 +187,7 @@ GLFWAPI void glfwSetKeyCallback(GLFWwindow window, GLFWkeyfun cbfun)
// Set callback function for character input // Set callback function for character input
//======================================================================== //========================================================================
GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun) GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -195,7 +195,7 @@ GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun)
return; return;
} }
window->charCallback = cbfun; _glfwLibrary.charCallback = cbfun;
} }
@ -203,7 +203,7 @@ GLFWAPI void glfwSetCharCallback(GLFWwindow window, GLFWcharfun cbfun)
// Set callback function for mouse clicks // Set callback function for mouse clicks
//======================================================================== //========================================================================
GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cbfun) GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -211,7 +211,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cb
return; return;
} }
window->mouseButtonCallback = cbfun; _glfwLibrary.mouseButtonCallback = cbfun;
} }
@ -219,7 +219,7 @@ GLFWAPI void glfwSetMouseButtonCallback(GLFWwindow window, GLFWmousebuttonfun cb
// Set callback function for mouse moves // Set callback function for mouse moves
//======================================================================== //========================================================================
GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun) GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -228,20 +228,25 @@ GLFWAPI void glfwSetMousePosCallback(GLFWwindow window, GLFWmouseposfun cbfun)
} }
// Set callback function // Set callback function
window->mousePosCallback = cbfun; _glfwLibrary.mousePosCallback = cbfun;
// Call the callback function to let the application know the current // Call the callback function to let the application know the current
// mouse position // mouse position
if (cbfun) if (cbfun)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
cbfun(window, window->mousePosX, window->mousePosY); cbfun(window, window->mousePosX, window->mousePosY);
} }
}
//======================================================================== //========================================================================
// Set callback function for scroll events // Set callback function for scroll events
//======================================================================== //========================================================================
GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun) GLFWAPI void glfwSetScrollCallback(GLFWscrollfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -250,11 +255,6 @@ GLFWAPI void glfwSetScrollCallback(GLFWwindow window, GLFWscrollfun cbfun)
} }
// Set callback function // Set callback function
window->scrollCallback = cbfun; _glfwLibrary.scrollCallback = cbfun;
// Call the callback function to let the application know the current
// scroll offset
if (cbfun)
cbfun(window, window->scrollX, window->scrollY);
} }

View File

@ -152,18 +152,6 @@ struct _GLFWwindow
{ {
struct _GLFWwindow* next; 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 // Window settings and state
GLboolean iconified; // GL_TRUE if this window is iconified GLboolean iconified; // GL_TRUE if this window is iconified
GLboolean closeRequested; // GL_TRUE if this window should be closed GLboolean closeRequested; // GL_TRUE if this window should be closed
@ -223,6 +211,17 @@ struct _GLFWlibrary
_GLFWwindow* activeWindow; _GLFWwindow* activeWindow;
_GLFWwindow* cursorLockWindow; _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 currentRamp;
GLFWgammaramp originalRamp; GLFWgammaramp originalRamp;
int originalRampSize; int originalRampSize;

View File

@ -713,8 +713,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{ {
window->iconified = iconified; window->iconified = iconified;
if (window->windowIconifyCallback) if (_glfwLibrary.windowIconifyCallback)
window->windowIconifyCallback(window, window->iconified); _glfwLibrary.windowIconifyCallback(window, window->iconified);
} }
return 0; return 0;
@ -756,7 +756,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{ {
_glfwInputKey(window, translateKey(wParam, lParam), GLFW_PRESS); _glfwInputKey(window, translateKey(wParam, lParam), GLFW_PRESS);
if (window->charCallback) if (_glfwLibrary.charCallback)
translateChar(window, (DWORD) wParam, (DWORD) lParam); translateChar(window, (DWORD) wParam, (DWORD) lParam);
return 0; return 0;
@ -879,9 +879,9 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
window->Win32.oldMouseY = newMouseY; window->Win32.oldMouseY = newMouseY;
window->Win32.mouseMoved = GL_TRUE; window->Win32.mouseMoved = GL_TRUE;
if (window->mousePosCallback) if (_glfwLibrary.mousePosCallback)
{ {
window->mousePosCallback(window, _glfwLibrary.mousePosCallback(window,
window->mousePosX, window->mousePosX,
window->mousePosY); window->mousePosY);
} }
@ -917,8 +917,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
ClipCursor(&ClipWindowRect); ClipCursor(&ClipWindowRect);
} }
if (window->windowSizeCallback) if (_glfwLibrary.windowSizeCallback)
window->windowSizeCallback(window, window->width, window->height); _glfwLibrary.windowSizeCallback(window, window->width, window->height);
return 0; return 0;
} }
@ -941,8 +941,8 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
// Was the window contents damaged? // Was the window contents damaged?
case WM_PAINT: case WM_PAINT:
{ {
if (window->windowRefreshCallback) if (_glfwLibrary.windowRefreshCallback)
window->windowRefreshCallback(window); _glfwLibrary.windowRefreshCallback(window);
break; break;
} }

View File

@ -55,8 +55,8 @@ static void closeFlaggedWindows(void)
for (window = _glfwLibrary.windowListHead; window; ) for (window = _glfwLibrary.windowListHead; window; )
{ {
if (window->closeRequested && window->windowCloseCallback) if (window->closeRequested && _glfwLibrary.windowCloseCallback)
window->closeRequested = window->windowCloseCallback(window); window->closeRequested = _glfwLibrary.windowCloseCallback(window);
if (window->closeRequested) if (window->closeRequested)
{ {
@ -144,8 +144,8 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
} }
// Call user callback function // Call user callback function
if (window->keyCallback && (window->keyRepeat || !keyrepeat)) if (_glfwLibrary.keyCallback && (window->keyRepeat || !keyrepeat))
window->keyCallback(window, key, action); _glfwLibrary.keyCallback(window, key, action);
} }
@ -159,8 +159,8 @@ void _glfwInputChar(_GLFWwindow* window, int character)
if (!((character >= 32 && character <= 126) || character >= 160)) if (!((character >= 32 && character <= 126) || character >= 160))
return; return;
if (window->charCallback) if (_glfwLibrary.charCallback)
window->charCallback(window, character); _glfwLibrary.charCallback(window, character);
} }
@ -173,8 +173,8 @@ void _glfwInputScroll(_GLFWwindow* window, int x, int y)
window->scrollX += x; window->scrollX += x;
window->scrollY += y; window->scrollY += y;
if (window->scrollCallback) if (_glfwLibrary.scrollCallback)
window->scrollCallback(window, x, y); _glfwLibrary.scrollCallback(window, x, y);
} }
@ -193,8 +193,8 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action)
else else
window->mouseButton[button] = (char) action; window->mouseButton[button] = (char) action;
if (window->mouseButtonCallback) if (_glfwLibrary.mouseButtonCallback)
window->mouseButtonCallback(window, button, action); _glfwLibrary.mouseButtonCallback(window, button, action);
} }
@ -210,8 +210,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated)
{ {
_glfwLibrary.activeWindow = window; _glfwLibrary.activeWindow = window;
if (window->windowFocusCallback) if (_glfwLibrary.windowFocusCallback)
window->windowFocusCallback(window, activated); _glfwLibrary.windowFocusCallback(window, activated);
} }
} }
else else
@ -236,8 +236,8 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated)
_glfwLibrary.activeWindow = NULL; _glfwLibrary.activeWindow = NULL;
if (window->windowFocusCallback) if (_glfwLibrary.windowFocusCallback)
window->windowFocusCallback(window, activated); _glfwLibrary.windowFocusCallback(window, activated);
} }
} }
} }
@ -1076,7 +1076,7 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow window)
// Set callback function for window size changes // Set callback function for window size changes
//======================================================================== //========================================================================
GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfun) GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -1084,19 +1084,24 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindow window, GLFWwindowsizefun cbfu
return; return;
} }
window->windowSizeCallback = cbfun; _glfwLibrary.windowSizeCallback = cbfun;
// Call the callback function to let the application know the current // Call the callback function to let the application know the current
// window size // window size
if (cbfun) if (cbfun)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
cbfun(window, window->width, window->height); cbfun(window, window->width, window->height);
} }
}
//======================================================================== //========================================================================
// Set callback function for window close events // Set callback function for window close events
//======================================================================== //========================================================================
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cbfun) GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -1104,7 +1109,7 @@ GLFWAPI void glfwSetWindowCloseCallback(GLFWwindow window, GLFWwindowclosefun cb
return; 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 // Set callback function for window refresh events
//======================================================================== //========================================================================
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfun cbfun) GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -1120,7 +1125,7 @@ GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfu
return; return;
} }
window->windowRefreshCallback = cbfun; _glfwLibrary.windowRefreshCallback = cbfun;
} }
@ -1128,7 +1133,7 @@ GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindow window, GLFWwindowrefreshfu
// Set callback function for window focus events // Set callback function for window focus events
//======================================================================== //========================================================================
GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cbfun) GLFWAPI void glfwSetWindowFocusCallback(GLFWwindowfocusfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -1136,7 +1141,7 @@ GLFWAPI void glfwSetWindowFocusCallback(GLFWwindow window, GLFWwindowfocusfun cb
return; 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 // Set callback function for window iconification events
//======================================================================== //========================================================================
GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfun cbfun) GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindowiconifyfun cbfun)
{ {
if (!_glfwInitialized) if (!_glfwInitialized)
{ {
@ -1152,7 +1157,7 @@ GLFWAPI void glfwSetWindowIconifyCallback(GLFWwindow window, GLFWwindowiconifyfu
return; return;
} }
window->windowIconifyCallback = cbfun; _glfwLibrary.windowIconifyCallback = cbfun;
} }

View File

@ -1197,9 +1197,9 @@ static void processSingleEvent(void)
window->X11.cursorPosY = event.xmotion.y; window->X11.cursorPosY = event.xmotion.y;
window->X11.mouseMoved = GL_TRUE; window->X11.mouseMoved = GL_TRUE;
if (window->mousePosCallback) if (_glfwLibrary.mousePosCallback)
{ {
window->mousePosCallback(window, _glfwLibrary.mousePosCallback(window,
window->mousePosX, window->mousePosX,
window->mousePosY); window->mousePosY);
} }
@ -1224,9 +1224,9 @@ static void processSingleEvent(void)
window->width = event.xconfigure.width; window->width = event.xconfigure.width;
window->height = event.xconfigure.height; window->height = event.xconfigure.height;
if (window->windowSizeCallback) if (_glfwLibrary.windowSizeCallback)
{ {
window->windowSizeCallback(window, _glfwLibrary.windowSizeCallback(window,
window->width, window->width,
window->height); window->height);
} }
@ -1288,8 +1288,8 @@ static void processSingleEvent(void)
window->iconified = GL_FALSE; window->iconified = GL_FALSE;
if (window->windowIconifyCallback) if (_glfwLibrary.windowIconifyCallback)
window->windowIconifyCallback(window, window->iconified); _glfwLibrary.windowIconifyCallback(window, window->iconified);
break; break;
} }
@ -1306,8 +1306,8 @@ static void processSingleEvent(void)
window->iconified = GL_TRUE; window->iconified = GL_TRUE;
if (window->windowIconifyCallback) if (_glfwLibrary.windowIconifyCallback)
window->windowIconifyCallback(window, window->iconified); _glfwLibrary.windowIconifyCallback(window, window->iconified);
break; break;
} }
@ -1358,8 +1358,8 @@ static void processSingleEvent(void)
return; return;
} }
if (window->windowRefreshCallback) if (_glfwLibrary.windowRefreshCallback)
window->windowRefreshCallback(window); _glfwLibrary.windowRefreshCallback(window);
break; break;
} }

View File

@ -74,8 +74,8 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetMousePosCallback(window, mouse_position_callback); glfwSetMousePosCallback(mouse_position_callback);
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
glClearColor(0, 0, 0, 0); glClearColor(0, 0, 0, 0);

View File

@ -303,16 +303,16 @@ int main(void)
glfwSwapInterval(1); glfwSwapInterval(1);
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowCloseCallback(window_close_callback);
glfwSetWindowRefreshCallback(window, window_refresh_callback); glfwSetWindowRefreshCallback(window_refresh_callback);
glfwSetWindowFocusCallback(window, window_focus_callback); glfwSetWindowFocusCallback(window_focus_callback);
glfwSetWindowIconifyCallback(window, window_iconify_callback); glfwSetWindowIconifyCallback(window_iconify_callback);
glfwSetMouseButtonCallback(window, mouse_button_callback); glfwSetMouseButtonCallback(mouse_button_callback);
glfwSetMousePosCallback(window, mouse_position_callback); glfwSetMousePosCallback(mouse_position_callback);
glfwSetScrollCallback(window, scroll_callback); glfwSetScrollCallback(scroll_callback);
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
glfwSetCharCallback(window, char_callback); glfwSetCharCallback(char_callback);
printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled"); printf("Key repeat should be %s\n", keyrepeat ? "enabled" : "disabled");
printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled"); printf("System keys should be %s\n", systemkeys ? "enabled" : "disabled");

View File

@ -65,7 +65,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
samples = glfwGetWindowParam(window, GLFW_FSAA_SAMPLES); samples = glfwGetWindowParam(window, GLFW_FSAA_SAMPLES);

View File

@ -93,9 +93,9 @@ int main(void)
glfwSwapInterval(1); glfwSwapInterval(1);
glfwEnable(window, GLFW_MOUSE_CURSOR); glfwEnable(window, GLFW_MOUSE_CURSOR);
glfwSetWindowFocusCallback(window, window_focus_callback); glfwSetWindowFocusCallback(window_focus_callback);
glfwSetKeyCallback(window, window_key_callback); glfwSetKeyCallback(window_key_callback);
glfwSetWindowCloseCallback(window, window_close_callback); glfwSetWindowCloseCallback(window_close_callback);
while (running && glfwIsWindow(window) == GL_TRUE) while (running && glfwIsWindow(window) == GL_TRUE)
{ {

View File

@ -149,8 +149,8 @@ int main(int argc, char** argv)
ggamma, ggain, gblacklevel); ggamma, ggain, gblacklevel);
glfwSwapInterval(1); glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
glfwSetWindowSizeCallback(window, size_callback); glfwSetWindowSizeCallback(size_callback);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);

View File

@ -119,8 +119,8 @@ int main(int argc, char** argv)
} }
glfwSwapInterval(1); glfwSwapInterval(1);
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
glfwSetWindowSizeCallback(window, size_callback); glfwSetWindowSizeCallback(size_callback);
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);

View File

@ -96,9 +96,9 @@ static GLboolean open_window(void)
glfwGetMousePos(window_handle, &x, &y); glfwGetMousePos(window_handle, &x, &y);
printf("Mouse position: %i %i\n", x, y); printf("Mouse position: %i %i\n", x, y);
glfwSetWindowSizeCallback(window_handle, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSetMousePosCallback(window_handle, mouse_position_callback); glfwSetMousePosCallback(mouse_position_callback);
glfwSetKeyCallback(window_handle, key_callback); glfwSetKeyCallback(key_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
return GL_TRUE; return GL_TRUE;

View File

@ -91,9 +91,9 @@ static int open_window(int width, int height, int mode)
return 0; return 0;
} }
glfwSetWindowSizeCallback(window_handle, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSetWindowCloseCallback(window_handle, window_close_callback); glfwSetWindowCloseCallback(window_close_callback);
glfwSetKeyCallback(window_handle, key_callback); glfwSetKeyCallback(key_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
printf("Opening %s mode window took %0.3f seconds\n", printf("Opening %s mode window took %0.3f seconds\n",

View File

@ -49,7 +49,7 @@ static GLFWwindow open_window(const char* title, GLFWwindow share)
if (!window) if (!window)
return NULL; return NULL;
glfwSetKeyCallback(window, key_callback); glfwSetKeyCallback(key_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
return window; return window;

View File

@ -59,7 +59,7 @@ int main(void)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowSizeCallback(window, window_size_callback); glfwSetWindowSizeCallback(window_size_callback);
glfwSwapInterval(1); glfwSwapInterval(1);
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);