mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 05:22:00 +00:00
Removed calling of callbacks from setters.
This commit is contained in:
parent
c55f84ef3f
commit
8ed66ea4d5
@ -579,6 +579,7 @@ void DrawGrid( void )
|
|||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
/* Init GLFW */
|
/* Init GLFW */
|
||||||
if( !glfwInit() )
|
if( !glfwInit() )
|
||||||
@ -587,6 +588,9 @@ int main( void )
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwSetWindowCloseCallback( window_close_callback );
|
||||||
|
glfwSetWindowSizeCallback( reshape );
|
||||||
|
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||||
|
|
||||||
window = glfwCreateWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL );
|
window = glfwCreateWindow( 400, 400, GLFW_WINDOWED, "Boing (classic Amiga demo)", NULL );
|
||||||
@ -597,8 +601,9 @@ int main( void )
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
glfwSetWindowCloseCallback( window_close_callback );
|
glfwGetWindowSize(window, &width, &height);
|
||||||
glfwSetWindowSizeCallback( reshape );
|
reshape(window, width, height);
|
||||||
|
|
||||||
glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
|
glfwSetInputMode( window, GLFW_STICKY_KEYS, GL_TRUE );
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
glfwSetTime( 0.0 );
|
glfwSetTime( 0.0 );
|
||||||
|
@ -330,6 +330,7 @@ static void init(int argc, char *argv[])
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
if( !glfwInit() )
|
if( !glfwInit() )
|
||||||
{
|
{
|
||||||
@ -337,6 +338,11 @@ int main(int argc, char *argv[])
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set callback functions
|
||||||
|
glfwSetWindowCloseCallback(window_close_callback);
|
||||||
|
glfwSetWindowSizeCallback( reshape );
|
||||||
|
glfwSetKeyCallback( key );
|
||||||
|
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||||
|
|
||||||
window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL );
|
window = glfwCreateWindow( 300, 300, GLFW_WINDOWED, "Gears", NULL );
|
||||||
@ -347,17 +353,15 @@ int main(int argc, char *argv[])
|
|||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
reshape(window, width, height);
|
||||||
|
|
||||||
glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE );
|
glfwSetInputMode( window, GLFW_KEY_REPEAT, GL_TRUE );
|
||||||
glfwSwapInterval( 1 );
|
glfwSwapInterval( 1 );
|
||||||
|
|
||||||
// Parse command-line options
|
// Parse command-line options
|
||||||
init(argc, argv);
|
init(argc, argv);
|
||||||
|
|
||||||
// Set callback functions
|
|
||||||
glfwSetWindowCloseCallback(window_close_callback);
|
|
||||||
glfwSetWindowSizeCallback( reshape );
|
|
||||||
glfwSetKeyCallback( key );
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
while( running )
|
while( running )
|
||||||
{
|
{
|
||||||
|
@ -456,6 +456,7 @@ static int windowCloseFun(GLFWwindow window)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
// Initialise GLFW
|
// Initialise GLFW
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
@ -464,6 +465,13 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set callback functions
|
||||||
|
glfwSetWindowCloseCallback(windowCloseFun);
|
||||||
|
glfwSetWindowSizeCallback(windowSizeFun);
|
||||||
|
glfwSetWindowRefreshCallback(windowRefreshFun);
|
||||||
|
glfwSetCursorPosCallback(cursorPosFun);
|
||||||
|
glfwSetMouseButtonCallback(mouseButtonFun);
|
||||||
|
|
||||||
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
glfwWindowHint(GLFW_DEPTH_BITS, 16);
|
||||||
|
|
||||||
// Open OpenGL window
|
// Open OpenGL window
|
||||||
@ -474,6 +482,9 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
windowSizeFun(window, width, height);
|
||||||
|
|
||||||
// Enable vsync
|
// Enable vsync
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
@ -483,13 +494,6 @@ int main(void)
|
|||||||
// Enable mouse cursor (only needed for fullscreen mode)
|
// Enable mouse cursor (only needed for fullscreen mode)
|
||||||
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
|
||||||
|
|
||||||
// Set callback functions
|
|
||||||
glfwSetWindowCloseCallback(windowCloseFun);
|
|
||||||
glfwSetWindowSizeCallback(windowSizeFun);
|
|
||||||
glfwSetWindowRefreshCallback(windowRefreshFun);
|
|
||||||
glfwSetCursorPosCallback(cursorPosFun);
|
|
||||||
glfwSetMouseButtonCallback(mouseButtonFun);
|
|
||||||
|
|
||||||
// Main loop
|
// Main loop
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -355,7 +355,7 @@ void scroll_callback(GLFWwindow window, double x, double y)
|
|||||||
// Callback function for window resize events
|
// 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;
|
float ratio = 1.f;
|
||||||
|
|
||||||
@ -391,6 +391,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
double t, dt_total, t_old;
|
double t, dt_total, t_old;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
@ -398,6 +399,13 @@ int main(int argc, char* argv[])
|
|||||||
exit(EXIT_FAILURE);
|
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);
|
window = glfwCreateWindow(640, 480, GLFW_WINDOWED, "Wave Simulation", NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
@ -405,19 +413,13 @@ int main(int argc, char* argv[])
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
window_size_callback(window, width, height);
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
|
|
||||||
// Keyboard handler
|
|
||||||
glfwSetKeyCallback(key_callback);
|
|
||||||
glfwSetInputMode(window, GLFW_KEY_REPEAT, GL_TRUE);
|
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
|
// Initialize OpenGL
|
||||||
init_opengl();
|
init_opengl();
|
||||||
|
|
||||||
|
10
src/input.c
10
src/input.c
@ -551,16 +551,6 @@ GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfwLibrary.cursorPosCallback = 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
10
src/window.c
10
src/window.c
@ -762,16 +762,6 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun)
|
|||||||
}
|
}
|
||||||
|
|
||||||
_glfwLibrary.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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
int width, height;
|
||||||
|
|
||||||
if (!glfwInit())
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
@ -87,6 +88,10 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwSetCursorPosCallback(cursor_position_callback);
|
||||||
|
glfwSetWindowSizeCallback(window_size_callback);
|
||||||
|
glfwSetKeyCallback(key_callback);
|
||||||
|
|
||||||
window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL);
|
window = glfwCreateWindow(window_width, window_height, GLFW_WINDOWED, "", NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
@ -96,11 +101,10 @@ int main(void)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_swap_interval(window, swap_interval);
|
glfwGetWindowSize(window, &width, &height);
|
||||||
|
window_size_callback(window, width, height);
|
||||||
|
|
||||||
glfwSetCursorPosCallback(cursor_position_callback);
|
set_swap_interval(window, swap_interval);
|
||||||
glfwSetWindowSizeCallback(window_size_callback);
|
|
||||||
glfwSetKeyCallback(key_callback);
|
|
||||||
|
|
||||||
while (glfwGetCurrentContext())
|
while (glfwGetCurrentContext())
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user