• 10
• 9
• 13
• 10
• 18

OpenGL Clock

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

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 on other sites
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 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!