Results 1 to 8 of 8

Thread: Game timer !!

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    India
    Posts
    24

    Game timer !!

    Hello Folks !!

    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 !!!
    <span style="color: #000090">Thanks for your prompt response in advance !!</span>

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: Game timer !!

    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()

  3. #3
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Game timer !!

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    India
    Posts
    24

    Re: Game timer !!

    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 ??
    <span style="color: #000090">Thanks for your prompt response in advance !!</span>

  5. #5
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Game timer !!

    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.

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    India
    Posts
    24

    Re: Game timer !!

    Code :
    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 ??
    <span style="color: #000090">Thanks for your prompt response in advance !!</span>

  7. #7
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,161

    Re: Game timer !!

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

    Looks OK otherwise.

  8. #8
    Junior Member Newbie
    Join Date
    Nov 2011
    Location
    India
    Posts
    24

    Re: Game timer !!

    Any idea on this post BionicBytes ??

    http://www.opengl.org/discussion_boa...000#Post307000
    <span style="color: #000090">Thanks for your prompt response in advance !!</span>

Similar Threads

  1. timer
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 01-08-2006, 04:55 PM
  2. TIMER?????
    By HajiHeydari in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-05-2005, 01:21 AM
  3. timer
    By zukko in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-11-2004, 11:00 AM
  4. timer
    By Vlasko in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 05-25-2003, 11:35 PM
  5. using timer with glx?
    By jasc in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-19-2002, 02:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean