/** This will stop a timing. If a timing was not started, the function will return false.
@returns true is timing has stopped, false is a timing was not started.
*/
bool BaseTimer2::stop(){
	if (__start != 0) {
		__stop = GetPerformanceTicks();
		return true;
	}
	else return false;
}
Example #2
0
File: main.cpp Project: Jadela/GT1
//Render the objects
void display()
{
	// Get CPU time from start.
	CPUtime = GetPerformanceTicks();

	// Initialize the physics time at the beginning of the program.
	if ( CPUphysicsTime == 0 )
		CPUphysicsTime = CPUtime - CPUphysicsTimeStep;

	while ( (CPUphysicsTime + CPUphysicsTimeStep) <= CPUtime )
	{
		physEngine.Update(physicsTimestep);
		CPUphysicsTime += CPUphysicsTimeStep;
	}

	//Make sure we do not get ahead of current time due to rounding errors
	if ( CPUphysicsTime > CPUtime )
		CPUphysicsTime = CPUtime;

	//Render section
	physEngine.Render();

	//Display the results
	glEnable( GL_BLEND );
	glPopMatrix();
	glutSwapBuffers();
	glClear( GL_COLOR_BUFFER_BIT );
}