Application.cpp
// Call PreUpdate, Update and PostUpdate on all modules
Call PreUpdate, Update and PostUpdate on all modules
Call PreUpdate Update and PostUpdate on all modules
update_status Application::Update()
{
	frameCount++;
	lastSecFrameCount++;
	dt = frameTime.Read();
	frameTime.Start();
	update_status ret = UPDATE_CONTINUE;
	p2List_item<Module*>* item = list_modules.getFirst();
	while(item != NULL && ret == UPDATE_CONTINUE)
	{
		if(item->data->IsEnabled())
			ret = item->data->PreUpdate();
		item = item->next;
	}
	item = list_modules.getFirst();
	while(item != NULL && ret == UPDATE_CONTINUE)
	{
		if(item->data->IsEnabled())
  			ret = item->data->Update(dt);
		item = item->next;
	}
	item = list_modules.getFirst();
	while(item != NULL && ret == UPDATE_CONTINUE)
	{
		if(item->data->IsEnabled())
			ret = item->data->PostUpdate();
		item = item->next;
	}
	if (lastSecFrameTime.Read() > 1000)
	{
		lastSecFrameTime.Start();
		prevLastSecFrameCount = lastSecFrameCount;
		lastSecFrameCount = 0;
	}
	float averageFps = float(frameCount) / startupTime.ReadSec();
	float secondsSinceStartup = startupTime.ReadSec();
	uint lastFrameMs = frameTime.Read();
	uint framesOnLastUpdate = prevLastSecFrameCount;
	static char title[256];
	sprintf_s(title, 256, "Super Apollo Odyssey");
	window->SetTitle(title);
	if (maxFPS > 0 && lastFrameMs < maxFPS)
	{
		PERF_START(ptimer);
		SDL_Delay(maxFPS-lastFrameMs);
		PERF_PEEK(ptimer);
	}
	return ret;
}
update_status Application :: Update ( ) { frameCount ++ ; lastSecFrameCount ++ ; dt = frameTime . Read ( ) ; frameTime . Start ( ) ; update_status ret = UPDATE_CONTINUE ; p2List_item < Module * > * item = list_modules . getFirst ( ) ; while ( item != NULL && ret == UPDATE_CONTINUE ) { if ( item -> data -> IsEnabled ( ) ) ret = item -> data -> PreUpdate ( ) ; item = item -> next ; } item = list_modules . getFirst ( ) ; while ( item != NULL && ret == UPDATE_CONTINUE ) { if ( item -> data -> IsEnabled ( ) ) ret = item -> data -> Update ( dt ) ; item = item -> next ; } item = list_modules . getFirst ( ) ; while ( item != NULL && ret == UPDATE_CONTINUE ) { if ( item -> data -> IsEnabled ( ) ) ret = item -> data -> PostUpdate ( ) ; item = item -> next ; } if ( lastSecFrameTime . Read ( ) > 1000 ) { lastSecFrameTime . Start ( ) ; prevLastSecFrameCount = lastSecFrameCount ; lastSecFrameCount = 0 ; } float averageFps = float ( frameCount ) / startupTime . ReadSec ( ) ; float secondsSinceStartup = startupTime . ReadSec ( ) ; uint lastFrameMs = frameTime . Read ( ) ; uint framesOnLastUpdate = prevLastSecFrameCount ; static char title [ 256 ] ; sprintf_s ( title , 256 , " " ) ; window -> SetTitle ( title ) ; if ( maxFPS > 0 && lastFrameMs < maxFPS ) { PERF_START ( ptimer ) ; SDL_Delay ( maxFPS - lastFrameMs ) ; PERF_PEEK ( ptimer ) ; } return ret ; }
Call PreUpdate, Update and PostUpdate on all modules
Call PreUpdate Update and PostUpdate on all modules
//dt = frameTime.ReadSec(); //frameTime.Start();