void timerFunc(int nValue) { FMOD_RESULT result; doGeometryMovement(); doSoundMovement(); doListenerMovement(); result = fmodSystem->update(); ERRCHECK(result); accumulatedTime += (float)INTERFACE_UPDATETIME / 1000.0f; glutPostRedisplay(); glutTimerFunc(INTERFACE_UPDATETIME, timerFunc, 0); if (0) { float dsp, stream, geom, update, total; int chansplaying; fmodSystem->getCPUUsage(&dsp, &stream, &geom, &update, &total); fmodSystem->getChannelsPlaying(&chansplaying); printf("chans %d : cpu : dsp = %.02f stream = %.02f geometry = %.02f update = %.02f total = %.02f\n", chansplaying, dsp, stream, geometry, update, total); } }
void idle() { static unsigned int fpsCounter = 0; static float fps = 0.0f; static float prevTime = (float)glutGet(GLUT_ELAPSED_TIME); //(float)clock(); fpsCounter++; float currTime = (float)glutGet(GLUT_ELAPSED_TIME); //(float)clock(); accumulatedTime = currTime / 1000.0f; float delta = currTime - prevTime; if (delta > 1000.0f) { interfaceUpdatTime = delta / (float)fpsCounter; fps = 1000.0f / interfaceUpdatTime; prevTime = currTime; fpsCounter = 0; } doGeometryMovement(); doSoundMovement(); doListenerMovement(); ERRCHECK(fmodSystem->update()); float dsp, stream, geom, update, total; int channels; fmodSystem->getCPUUsage(&dsp, &stream, &geom, &update, &total); fmodSystem->getChannelsPlaying(&channels); glPrintF(1, 1, "FPS : %02.1f", fps); glPrintF(2, 1, "FMOD CPU load : %.3f", total); glPrintF(3, 1, " | DSP : %.3f", dsp); glPrintF(4, 1, " | stream : %.3f", stream); glPrintF(5, 1, " | geometry: %.3f", geom); glPrintF(6, 1, " | update : %.3f", update); glPrintF(7, 1, "active channels : %i", channels); glutSwapBuffers(); glutPostRedisplay(); }