示例#1
0
//
// Draw Hud
//
void DrawHUD(void)
{

    glLoadIdentity();

    // change the matrix
    glMatrixMode(GL_PROJECTION);

    // current view
    glPushMatrix();

    // Begin normal code

    // reset the matrix
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();

    gluPerspective(45.0f, (GLfloat)SCREEN_WIDTH /
                   (GLfloat)SCREEN_HEIGHT, 0.1f, PERSPECTIVE_Z);

    glMatrixMode(GL_MODELVIEW);


    GetFramesPerSecond();	// get frames

} // end of the function
std::string MainLoopTimer::GetFPS () 
{
	std::ostringstream stream;
    stream.setf(std::ios::fixed | std::ios::showpoint);
    stream.precision(1);
    stream << "fps: " << GetFramesPerSecond();
    return stream.str();
}
//
// Draw Hud
//
void DrawHUD(void)
{

	glLoadIdentity();

	// change the matrix
	glMatrixMode(GL_PROJECTION);

	// current view
	glPushMatrix();

#if ENABLE_HUD

	glDisable(GL_LIGHTING);

	// setup projectino for text
	glLoadIdentity();
	glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1.0, 1.0);

	// get rid of textured text
	glDisable(GL_TEXTURE_2D);

	// dont need depth test
	glDisable(GL_DEPTH_TEST);

	// draw variables
	glColor3f(1.0, 1.0, 0.0);

	glRasterPos2i(10, 48);
	PrintText("FPS: %0.2f", framerate);

	PrintGlobals();

	glPopMatrix();		// end 

	// reset the textures
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_DEPTH_TEST);

	glEnable(GL_LIGHTING);

#endif

	// Begin normal code

	// reset the matrix
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluPerspective(45.0f, (GLfloat)SCREEN_WIDTH /
		(GLfloat)SCREEN_HEIGHT, 0.1f, PERSPECTIVE_Z);

	glMatrixMode(GL_MODELVIEW);


	GetFramesPerSecond();	// get frames

} // end of the function
double MarkersMotion::GetTimeStep()
{
	// By inverting our frames per second, we obtain the time interval between
	// frames (in fractions of a second)
	return 1.0f/GetFramesPerSecond();
}