This snatch of code from Alien Flux is what I use:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| if (!GL.WGL_EXT_swap_control) { float elapsed = 0.0f; frameTime = 0.0f; do { long now = Sys.getTime(); elapsed = (float)(now - then) / (float)Sys.getTimerResolution(); if (frameTime == 0.0f) frameTime = elapsed; if (elapsed < FRAME_TIME) Thread.sleep(1); } while (elapsed < FRAME_TIME); gl.swapBuffers(); } else { long now = Sys.getTime(); frameTime = (float)(now - then) / (float)Sys.getTimerResolution(); gl.swapBuffers(); } |
If it can't get WGL_EXT_swap_control I've found that doing loads of tiny sleeps is lighter on the CPU than a processor-hogging busy loop. Especially as I run at high priority.
Cas
