mirror of
https://github.com/glfw/glfw.git
synced 2026-01-11 23:33:16 +01:00
Made window-related callbacks per-window.
This makes polymorphic behaviour easier to implement and avoids the problem of events being triggered before the GLFW window object is fully usable.
This commit is contained in:
@@ -450,12 +450,6 @@ int main(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowSizeCallback(windowSizeFun);
|
||||
glfwSetWindowRefreshCallback(windowRefreshFun);
|
||||
glfwSetCursorPosCallback(cursorPosFun);
|
||||
glfwSetMouseButtonCallback(mouseButtonFun);
|
||||
|
||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||
|
||||
// Open OpenGL window
|
||||
@@ -468,6 +462,12 @@ int main(void)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Set callback functions
|
||||
glfwSetWindowSizeCallback(window, windowSizeFun);
|
||||
glfwSetWindowRefreshCallback(window, windowRefreshFun);
|
||||
glfwSetCursorPosCallback(window, cursorPosFun);
|
||||
glfwSetMouseButtonCallback(window, mouseButtonFun);
|
||||
|
||||
// Enable vsync
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1);
|
||||
|
||||
Reference in New Issue
Block a user