OpenGL Clock

Started by
1 comment, last by Dark_Glitch 15 years, 4 months ago
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 :)
--------- ApochPiQ : <Serious Grammar Nazi Pet Peeve> FFS guys, it's spelled "dying". That is all. </Serious Grammar Nazi Pet Peeve>
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]
- Haptic
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!
--------- ApochPiQ : <Serious Grammar Nazi Pet Peeve> FFS guys, it's spelled "dying". That is all. </Serious Grammar Nazi Pet Peeve>

This topic is closed to new replies.

Advertisement