return 0; | return 0; | ||||
} | } | ||||
/* XXX This isn't an official GLUT function, yet */ | |||||
void * APIENTRY | |||||
glutGetProcAddress(const char *procName) | |||||
{ | |||||
#if defined(_WIN32) | |||||
return (void *) wglGetProcAddress((LPCSTR) procName); | |||||
#elif defined(GLX_ARB_get_proc_address) | |||||
return (void *) glXGetProcAddressARB((const GLubyte *) procName); | |||||
#else | |||||
return NULL; | |||||
#endif | |||||
} | |||||
/* ENDCENTRY */ | /* ENDCENTRY */ |
glutInitWindowPosition(__glutInitX, __glutInitY); | glutInitWindowPosition(__glutInitX, __glutInitY); | ||||
} | } | ||||
__glutInitTime(&unused); | __glutInitTime(&unused); | ||||
/* check if GLUT_FPS env var is set */ | |||||
{ | |||||
const char *fps = getenv("GLUT_FPS"); | |||||
if (fps) { | |||||
sscanf(fps, "%d", &__glutFPS); | |||||
if (__glutFPS <= 0) | |||||
__glutFPS = 5000; /* 5000 milliseconds */ | |||||
} | |||||
} | |||||
} | } | ||||
#ifdef _WIN32 | #ifdef _WIN32 |
and is provided without guarantee or warrantee expressed or | and is provided without guarantee or warrantee expressed or | ||||
implied. This program is -not- in the public domain. */ | implied. This program is -not- in the public domain. */ | ||||
#include <stdio.h> | |||||
#include "glutint.h" | #include "glutint.h" | ||||
GLint __glutFPS = 0; | |||||
GLint __glutSwapCount = 0; | |||||
GLint __glutSwapTime = 0; | |||||
/* CENTRY */ | /* CENTRY */ | ||||
void APIENTRY | void APIENTRY | ||||
glutSwapBuffers(void) | glutSwapBuffers(void) | ||||
glutPostRedisplay to trigger redraws. If | glutPostRedisplay to trigger redraws. If | ||||
glutPostRedisplay were used, __glutSetWindow would be | glutPostRedisplay were used, __glutSetWindow would be | ||||
called and a glFinish to throttle buffering would occur. */ | called and a glFinish to throttle buffering would occur. */ | ||||
if (__glutFPS) { | |||||
GLint t = glutGet(GLUT_ELAPSED_TIME); | |||||
__glutSwapCount++; | |||||
if (__glutSwapTime == 0) | |||||
__glutSwapTime = t; | |||||
else if (t - __glutSwapTime > __glutFPS) { | |||||
float time = 0.001 * (t - __glutSwapTime); | |||||
float fps = (float) __glutSwapCount / time; | |||||
fprintf(stderr, "GLUT: %d frames in %.2f seconds = %.2f FPS\n", | |||||
__glutSwapCount, time, fps); | |||||
__glutSwapTime = t; | |||||
__glutSwapCount = 0; | |||||
} | |||||
} | |||||
} | } | ||||
/* ENDCENTRY */ | /* ENDCENTRY */ |
/* private routines from glut_gameglut.c */ | /* private routines from glut_gameglut.c */ | ||||
extern void GLUTAPIENTRYV __glutCloseDownGameMode(void); | extern void GLUTAPIENTRYV __glutCloseDownGameMode(void); | ||||
/* private variables from glut_swap.c (BrianP) */ | |||||
extern GLint __glutFPS; | |||||
extern GLint __glutSwapCount; | |||||
extern GLint __glutSwapTime; | |||||
#if defined(_WIN32) | #if defined(_WIN32) | ||||
/* private routines from win32_*.c */ | /* private routines from win32_*.c */ | ||||
extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l); | extern LONG WINAPI __glutWindowProc(HWND win, UINT msg, WPARAM w, LPARAM l); |