Add GLUT_ELAPSED_TIME simulation

This commit is contained in:
Matthias Melcher 2023-02-20 13:40:27 +01:00
parent 6f4cf105b1
commit 2971625418
2 changed files with 14 additions and 3 deletions

View File

@ -315,12 +315,12 @@ enum {
GLUT_INIT_WINDOW_HEIGHT, GLUT_INIT_WINDOW_HEIGHT,
GLUT_INIT_DISPLAY_MODE, GLUT_INIT_DISPLAY_MODE,
GLUT_WINDOW_BUFFER_SIZE, GLUT_WINDOW_BUFFER_SIZE,
GLUT_VERSION GLUT_VERSION,
//GLUT_WINDOW_NUM_CHILDREN, //GLUT_WINDOW_NUM_CHILDREN,
//GLUT_WINDOW_CURSOR, //GLUT_WINDOW_CURSOR,
//GLUT_SCREEN_WIDTH_MM, //GLUT_SCREEN_WIDTH_MM,
//GLUT_SCREEN_HEIGHT_MM, //GLUT_SCREEN_HEIGHT_MM,
//GLUT_ELAPSED_TIME, GLUT_ELAPSED_TIME,
}; };
# define GLUT_WINDOW_STENCIL_SIZE GL_STENCIL_BITS # define GLUT_WINDOW_STENCIL_SIZE GL_STENCIL_BITS

View File

@ -190,8 +190,14 @@ Fl_Glut_Window::Fl_Glut_Window(int X,int Y,int W,int H, const char *t) :
static int initargc; static int initargc;
static char **initargv; static char **initargv;
static char glut_starttime_set = 0;
static Fl_Timestamp glut_starttime;
void glutInit(int *argc, char **argv) { void glutInit(int *argc, char **argv) {
if (!glut_starttime_set) {
glut_starttime = Fl::now();
glut_starttime_set = 1;
}
initargc = *argc; initargc = *argc;
initargv = new char*[*argc+1]; initargv = new char*[*argc+1];
int i,j; int i,j;
@ -405,7 +411,12 @@ int glutGet(GLenum type) {
case GLUT_INIT_WINDOW_WIDTH: return initw; case GLUT_INIT_WINDOW_WIDTH: return initw;
case GLUT_INIT_WINDOW_HEIGHT: return inith; case GLUT_INIT_WINDOW_HEIGHT: return inith;
case GLUT_INIT_DISPLAY_MODE: return glut_mode; case GLUT_INIT_DISPLAY_MODE: return glut_mode;
//case GLUT_ELAPSED_TIME: case GLUT_ELAPSED_TIME:
if (!glut_starttime_set) {
glut_starttime = Fl::now();
glut_starttime_set = 1;
}
return (int)(Fl::seconds_since(glut_starttime)*1000.0); // milliseconds
case GLUT_WINDOW_BUFFER_SIZE: case GLUT_WINDOW_BUFFER_SIZE:
if (glutGet(GLUT_WINDOW_RGBA)) if (glutGet(GLUT_WINDOW_RGBA))
return glutGet(GLUT_WINDOW_RED_SIZE)+ return glutGet(GLUT_WINDOW_RED_SIZE)+