Fix vsync

This commit is contained in:
hasufell 2014-05-17 17:24:29 +02:00
parent b5b35992c6
commit d3fe07c34d
No known key found for this signature in database
GPG Key ID: 220CD1C5BDEED020
3 changed files with 10 additions and 3 deletions

View File

@ -26,6 +26,7 @@
#include "err.h"
#include "filereader.h"
#include "gl_draw.h"
#include "half_edge.h"
#include <GL/glut.h>
@ -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();
}

View File

@ -31,6 +31,12 @@
#include <GL/glu.h>
/**
* Vsync timer for animate() function
*/
#define TIMERMSECS 25
void init(char const * const filename);
void display(void);
void reshape(GLsizei w, GLsizei h);

View File

@ -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;