|
|
|
@ -37,6 +37,21 @@ |
|
|
|
|
|
|
|
|
|
static int cursor_x = 0, cursor_y = 0; |
|
|
|
|
static int window_width = 640, window_height = 480; |
|
|
|
|
static int swap_interval = 1; |
|
|
|
|
|
|
|
|
|
static void set_swap_interval(GLFWwindow window, int interval) |
|
|
|
|
{ |
|
|
|
|
char title[256]; |
|
|
|
|
|
|
|
|
|
swap_interval = interval; |
|
|
|
|
glfwSwapInterval(swap_interval); |
|
|
|
|
|
|
|
|
|
snprintf(title, sizeof(title), |
|
|
|
|
"Cursor Inaccuracy Detector (interval %i)", |
|
|
|
|
swap_interval); |
|
|
|
|
|
|
|
|
|
glfwSetWindowTitle(window, title); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void window_size_callback(GLFWwindow window, int width, int height) |
|
|
|
|
{ |
|
|
|
@ -56,6 +71,12 @@ static void cursor_position_callback(GLFWwindow window, int x, int y) |
|
|
|
|
cursor_y = y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void key_callback(GLFWwindow window, int key, int action) |
|
|
|
|
{ |
|
|
|
|
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS) |
|
|
|
|
set_swap_interval(window, 1 - swap_interval); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(void) |
|
|
|
|
{ |
|
|
|
|
GLFWwindow window; |
|
|
|
@ -66,7 +87,7 @@ int main(void) |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "Cursor Inaccuracy Detector", NULL); |
|
|
|
|
window = glfwOpenWindow(window_width, window_height, GLFW_WINDOWED, "", NULL); |
|
|
|
|
if (!window) |
|
|
|
|
{ |
|
|
|
|
glfwTerminate(); |
|
|
|
@ -75,9 +96,11 @@ int main(void) |
|
|
|
|
exit(EXIT_FAILURE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
set_swap_interval(window, swap_interval); |
|
|
|
|
|
|
|
|
|
glfwSetCursorPosCallback(cursor_position_callback); |
|
|
|
|
glfwSetWindowSizeCallback(window_size_callback); |
|
|
|
|
glfwSwapInterval(1); |
|
|
|
|
glfwSetKeyCallback(key_callback); |
|
|
|
|
|
|
|
|
|
while (glfwGetCurrentContext()) |
|
|
|
|
{ |
|
|
|
|