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 );
}
glfwSetWindowSizeCallback( window, reshape );
glfwSetWindowSizeCallback( reshape );
glfwEnable( window, GLFW_STICKY_KEYS );
glfwSwapInterval( 1 );
glfwSetTime( 0.0 );

View File

@ -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 )

View File

@ -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())

View File

@ -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

View File

@ -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();

View File

@ -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);

View File

@ -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

View File

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

View File

@ -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,20 +228,25 @@ 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)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
cbfun(window, window->mousePosX, window->mousePosY);
}
}
//========================================================================
// 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;
}

View File

@ -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;

View File

@ -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,9 +879,9 @@ 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,
_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;
}

View File

@ -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)
{
_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;
}

View File

@ -1197,9 +1197,9 @@ static void processSingleEvent(void)
window->X11.cursorPosY = event.xmotion.y;
window->X11.mouseMoved = GL_TRUE;
if (window->mousePosCallback)
if (_glfwLibrary.mousePosCallback)
{
window->mousePosCallback(window,
_glfwLibrary.mousePosCallback(window,
window->mousePosX,
window->mousePosY);
}
@ -1224,9 +1224,9 @@ static void processSingleEvent(void)
window->width = event.xconfigure.width;
window->height = event.xconfigure.height;
if (window->windowSizeCallback)
if (_glfwLibrary.windowSizeCallback)
{
window->windowSizeCallback(window,
_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;
}

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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)
{

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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",

View File

@ -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;

View File

@ -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);