From d3fe07c34d1792f997440ce85bd326c8cdf21c59 Mon Sep 17 00:00:00 2001 From: hasufell Date: Sat, 17 May 2014 17:24:29 +0200 Subject: [PATCH] Fix vsync --- src/gl_draw.c | 5 +++-- src/gl_draw.h | 6 ++++++ src/main.c | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gl_draw.c b/src/gl_draw.c index 316bd4a..c5d3788 100644 --- a/src/gl_draw.c +++ b/src/gl_draw.c @@ -26,6 +26,7 @@ #include "err.h" #include "filereader.h" +#include "gl_draw.h" #include "half_edge.h" #include @@ -262,7 +263,7 @@ static void draw_Planet_1(void) glColor3f(1.0f, 0.0f, 0.0f); /* A rotation (full 360°) once a day is much - * too fast you woulden'd see a thing */ + * too fast you wouldn't see a thing */ glRotatef((ROT_FACTOR_PLANET * day) / rot_fac_day, 0.0f, 0.0f, 1.0f); glutWireSphere(1.0f, XY_WIRE_COUNT, XY_WIRE_COUNT); glRotatef((ROT_FACTOR_PLANET * day) / rot_fac_day, 0.0f, 0.0f, -1.0f); @@ -490,7 +491,7 @@ void animate() day = 0; } - usleep(30000); /* some very basic VScny to see the movement better */ + glutTimerFunc(TIMERMSECS, animate, 0); glutPostRedisplay(); } diff --git a/src/gl_draw.h b/src/gl_draw.h index 2f08cc6..9e3d6b6 100644 --- a/src/gl_draw.h +++ b/src/gl_draw.h @@ -31,6 +31,12 @@ #include +/** + * Vsync timer for animate() function + */ +#define TIMERMSECS 25 + + void init(char const * const filename); void display(void); void reshape(GLsizei w, GLsizei h); diff --git a/src/main.c b/src/main.c index 46f7121..c80618e 100644 --- a/src/main.c +++ b/src/main.c @@ -73,7 +73,7 @@ int main(int argc, char *argv[]) glutKeyboardFunc(keyboard); glutReshapeFunc(reshape); glutDisplayFunc(display); - glutIdleFunc(animate); + glutTimerFunc(TIMERMSECS, animate, 0); glutMainLoop(); return 0;