// IdleFunc() // Idle function for between frames void IdleFunc(void) { float deltaTime; // Mark time MarkTimeThisTick(); deltaTime = GetElapsedTime() * GAME_SPEED; // Call the display routine next time through the main loop glutPostRedisplay(); HUDClearScreen(); HUDPrintToScreen( "There is nothing to see but these text strings!!!\n\n" ); HUDPrintToScreen( "This app shows a bare minimum AI engine implemented.\n" ); HUDPrintToScreen( "Below you'll see the states of forty different game\n" ); HUDPrintToScreen( "objects as they wander around in space. See if you\n" ); HUDPrintToScreen( "can find a pattern. Then check the code to see if\n" ); HUDPrintToScreen( "you're right. Hint: Great AI makes the player believe\n" ); HUDPrintToScreen( "that the game is smarter than it really is.\n\n\n" ); //Send any messages that have been waiting SendDelayedMessages(); // Update all game objects in the AI engine GODBUpdate(); GODBOutputStateInfoToHUD(); }
void ProfileDumpOutputToBuffer( void ) { unsigned int i = 0; g_endProfile = GetExactTime(); MarkTimeThisTick(); string output; output += " Ave : Min : Max : # : Profile Name\n"; output += "--------------------------------------------\n"; while( i < NUM_PROFILE_SAMPLES && g_samples[i].bValid == true ) { unsigned int indent = 0; float sampleTime, percentTime, aveTime, minTime, maxTime; string indentedName; string ave, min, max, num; if( g_samples[i].iOpenProfiles < 0 ) { FAIL("ProfileEnd() called without a ProfileBegin()"); } else if( g_samples[i].iOpenProfiles > 0 ) { FAIL("ProfileBegin() called without a ProfileEnd()"); } sampleTime = g_samples[i].fAccumulator - g_samples[i].fChildrenSampleTime; float deltaTime = g_endProfile - g_startProfile; percentTime = ( sampleTime / deltaTime ) * 100.0f; aveTime = minTime = maxTime = percentTime; //Add new measurement into the history and get the ave, min, and max StoreProfileInHistory( g_samples[i].szName, percentTime ); GetProfileFromHistory( g_samples[i].szName, &aveTime, &minTime, &maxTime ); //Format the data const int fieldSize = 5; ave = Engine::ftoa(aveTime); min = Engine::ftoa(minTime); max = Engine::ftoa(maxTime); num = Engine::itoa(g_samples[i].iProfileInstances); ave = Engine::fitToFieldSize(ave, fieldSize, Engine::JUSTIFY_LEFT); min = Engine::fitToFieldSize(min, fieldSize, Engine::JUSTIFY_LEFT); max = Engine::fitToFieldSize(max, fieldSize, Engine::JUSTIFY_LEFT); num = Engine::fitToFieldSize(num, fieldSize, Engine::JUSTIFY_CENTER); indentedName.clear(); for(indent=0; indent<g_samples[i].iNumParents; indent++) indentedName += " "; indentedName += g_samples[i].szName; output += ave + " : " + min + " : " + max + " : " + num + " : " + indentedName + "\n"; i++; } { //Reset samples for next frame unsigned int i; for( i=0; i<NUM_PROFILE_SAMPLES; i++ ) { g_samples[i].bValid = false; } g_startProfile = GetExactTime(); } if(g_ProfileText) { g_ProfileText->setLabel(output); g_ProfileText->m_bVisible = g_Application.displayDebugData; } }