void eglutInit(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0) _eglut->display_name = argv[++i]; else if (strcmp(argv[i], "-info") == 0) { _eglut->verbose = 1; } } _eglutNativeInitDisplay(); _eglut->dpy = eglGetDisplay(_eglut->native_dpy); if (!eglInitialize(_eglut->dpy, &_eglut->major, &_eglut->minor)) _eglutFatal("failed to initialize EGL display"); _eglut->init_time = _eglutNow(); printf("EGL_VERSION = %s\n", eglQueryString(_eglut->dpy, EGL_VERSION)); if (_eglut->verbose) { printf("EGL_VENDOR = %s\n", eglQueryString(_eglut->dpy, EGL_VENDOR)); printf("EGL_EXTENSIONS = %s\n", eglQueryString(_eglut->dpy, EGL_EXTENSIONS)); printf("EGL_CLIENT_APIS = %s\n", eglQueryString(_eglut->dpy, EGL_CLIENT_APIS)); } }
void _eglutNativeEventLoop(void) { int start = _eglutNow(); int frames = 0; _eglut->redisplay = 1; while (1) { struct eglut_window *win = _eglut->current; int now = _eglutNow(); if (now - start > 5000) { double elapsed = (double) (now - start) / 1000.0; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, elapsed, frames / elapsed); fflush(stdout); start = now; frames = 0; /* send escape */ if (win->keyboard_cb) win->keyboard_cb(27); } if (_eglut->idle_cb) _eglut->idle_cb(); if (_eglut->redisplay) { _eglut->redisplay = 0; if (win->display_cb) win->display_cb(); eglSwapBuffers(_eglut->dpy, win->surface); frames++; } } }
int eglutGet(int state) { int val; switch (state) { case EGLUT_ELAPSED_TIME: val = _eglutNow() - _eglut->init_time; break; default: val = -1; break; } return val; }