Jump to content
  • Advertisement
Sign in to follow this  
Dark_Glitch

OpenGL Clock

This topic is 3560 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello again. I have been recently working on rotations and transformations in OpenGL and I decided to try my hand at making an analog clock. I have the code for the hands of the clock set up already that I've tested, now I have a problem that I solved once but can't remember how I did it. :P I need to make a timer that will, every 1000ms increase my second counter by 1. Thats it. However I can't seem to figure out WHAT to use. I've read that GetTickCount() updates slower than timeGetTime(), yet I've also ready stuff about QPC that I don't really understand. I'm under the impression that QPC is for timing your code to see how long it takes to execute. I'm not really interested in that right now, I just need a simple timer. What on earth should I use, and how do I go about using it properly? As always, thanks for the guidance :)

Share this post


Link to post
Share on other sites
Advertisement
Ive never used anything but timeGetTime(). I'm not sure if it's the best method accuracy wise or not, but if you were to use it, I would do something like this:

/* Where each second starts */
int StartTime = timeGetTime();

void UpdateTimer()
{

int CurrentTime = timeGetTime();
int Difference = CurrentTime - StartTime;

/* If a second has passed, update */
if( Difference >= 1000)
{
/* Reset start time */
StartTime += 1000;
SecondCounter ++;
}
}






Hope that helps,

[Edited by - Haptic on December 24, 2008 6:36:49 PM]

Share this post


Link to post
Share on other sites
Awesome. I knew it was something like that. I wasn't creating a start time variable with timeGetTime(). Its always something simpe that I miss :)

Now that the timer works I've started to debug my OpenGL code since it isn't quite fine tuned enough for this. The angles aren't coming out right at the 15, 30, 45 and 00 marks. I think I can figure this out though.

Thanks again!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!