Game timer !!

Hello Folks !! :slight_smile:

Is there any way to get the inbuilt timer of OpenGL !!

I want to implement stop timer in game, any idea how to implement…

And one silly question, where will be the glutBitmapCharacter() displayed !!

Out Of Time, pl reply soon !!!

Is there any way to get the inbuilt timer of OpenGL !!

No, there is no built in timer in OpenGL. There are timer queries, in case that is what you were thinking of, but those are used to get information about how long it takes OpenGL to process (parts of) the command stream.

glutBitmapCharacter draws at the current OpenGL raster position, see glRasterPos().

PS: if you are in such a hurry, you can get the answer to your second question much faster by looking up the man page for glutBitmapCharacter() :wink:

I want to implement stop timer in game, any idea how to implement…

Windows is event driven. Use a system timer.
Failing that, you could use GLUT timers if you are using Glut.
Failing all of the above, in the game loop read the real time clock and at X milliseconds from time Y, process an event.

Sorry for wrong interpretation, “stop timer” i actually mean a timer which keeps on ticking until the player reaches the destination…

Can you give some pointers on how to use it and i want to be shown at the top right corner, should i use another viewport for that or how ??

i want to be shown at the top right corner, should i use another viewport for that or how ??

Setup an orthographic projection with a viewport.
Disable depth testing and enable blend.

actually mean a timer which keeps on ticking until the player reaches the destination

Like I said, track the system time.

void showTime(){
   glPushAttrib(GL_ALL_ATTRIB_BITS);
   glPushMatrix();
   glDisable(GL_DEPTH_TEST);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
   glMatrixMode(GL_MODELVIEW);
   glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'T');
   glPopMatrix();
   glPopAttrib();
}

will this do ??

You need to add:
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE);

Looks OK otherwise.

Any idea on this post BionicBytes ??

http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=307000#Post307000