Fix vsync
This commit is contained in:
parent
b5b35992c6
commit
d3fe07c34d
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "err.h"
|
#include "err.h"
|
||||||
#include "filereader.h"
|
#include "filereader.h"
|
||||||
|
#include "gl_draw.h"
|
||||||
#include "half_edge.h"
|
#include "half_edge.h"
|
||||||
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
@ -262,7 +263,7 @@ static void draw_Planet_1(void)
|
|||||||
glColor3f(1.0f, 0.0f, 0.0f);
|
glColor3f(1.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
/* A rotation (full 360°) once a day is much
|
/* 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);
|
glRotatef((ROT_FACTOR_PLANET * day) / rot_fac_day, 0.0f, 0.0f, 1.0f);
|
||||||
glutWireSphere(1.0f, XY_WIRE_COUNT, XY_WIRE_COUNT);
|
glutWireSphere(1.0f, XY_WIRE_COUNT, XY_WIRE_COUNT);
|
||||||
glRotatef((ROT_FACTOR_PLANET * day) / rot_fac_day, 0.0f, 0.0f, -1.0f);
|
glRotatef((ROT_FACTOR_PLANET * day) / rot_fac_day, 0.0f, 0.0f, -1.0f);
|
||||||
@ -490,7 +491,7 @@ void animate()
|
|||||||
day = 0;
|
day = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(30000); /* some very basic VScny to see the movement better */
|
glutTimerFunc(TIMERMSECS, animate, 0);
|
||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +31,12 @@
|
|||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vsync timer for animate() function
|
||||||
|
*/
|
||||||
|
#define TIMERMSECS 25
|
||||||
|
|
||||||
|
|
||||||
void init(char const * const filename);
|
void init(char const * const filename);
|
||||||
void display(void);
|
void display(void);
|
||||||
void reshape(GLsizei w, GLsizei h);
|
void reshape(GLsizei w, GLsizei h);
|
||||||
|
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
|||||||
glutKeyboardFunc(keyboard);
|
glutKeyboardFunc(keyboard);
|
||||||
glutReshapeFunc(reshape);
|
glutReshapeFunc(reshape);
|
||||||
glutDisplayFunc(display);
|
glutDisplayFunc(display);
|
||||||
glutIdleFunc(animate);
|
glutTimerFunc(TIMERMSECS, animate, 0);
|
||||||
glutMainLoop();
|
glutMainLoop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user