diff --git a/src/input.c b/src/input.c index 8a0f1a8..9a4f60e 100644 --- a/src/input.c +++ b/src/input.c @@ -1,4 +1,5 @@ #include "main.h" +#include #include #include #include @@ -21,6 +22,12 @@ vec3 axis[3] = { extern struct projection projection; +void __error_callback_input(int x, const char * msg ) +{ + mlog("[GLFW] "); + mlog(msg); + mlog("\n"); +} void __key_callback_input( GLFWwindow *window, int key, int scancode, int action, int mods) { diff --git a/src/window.c b/src/window.c index 521e673..73b9d3a 100644 --- a/src/window.c +++ b/src/window.c @@ -8,6 +8,7 @@ void __mouse_callback_input(GLFWwindow *, int, int, int); void __scroll_callback_input(GLFWwindow *, double, double); void __key_callback_input(GLFWwindow *, int, int, int, int); void __drop_callback_input(GLFWwindow *, int, const char **); +void __error_callback_input(int, const char *); window_t init_window(unsigned int w, unsigned int h, const char *name); @@ -33,8 +34,12 @@ static void __limit_fps_window(int max_fps) struct timespec sleep_time; sleep_time.tv_sec = 0; sleep_time.tv_nsec = (long)((frame_time - elapsed_time) * 1e9); - nanosleep(&sleep_time, NULL); +#ifdef _WIN32 + usleep(sleep_time.tv_nsec/1000); +#else + nanosleep(&sleep_time, NULL); +#endif current_time = glfwGetTime(); } @@ -44,6 +49,7 @@ static void __limit_fps_window(int max_fps) window_t init_window(unsigned int width, unsigned int height, const char *title) { window_t window; + glfwSetErrorCallback(__error_callback_input); if (!glfwInit()) return NULL; @@ -51,6 +57,7 @@ window_t init_window(unsigned int width, unsigned int height, const char *title) glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, 1); window = (window_t)glfwCreateWindow(width, height, title, NULL, NULL); if (!(window)) @@ -67,8 +74,6 @@ window_t init_window(unsigned int width, unsigned int height, const char *title) glfwSetKeyCallback((GLFWwindow *)window, __key_callback_input); glfwSetDropCallback((GLFWwindow *)window, __drop_callback_input); - __window_callback_input((GLFWwindow *)window, width, height); - return window; }