new to mac

I realize this isn’t strictly openGL, sorry…

I’m trying my first bit of Mac programming. i’m taking a windows GLUT program I wrote and trying to compile it on a Mac. Everything’s working fine, but I’ve had to remove my Sleep() calls because I can’t seem to find an equivalent in the Mac world.

in Windows, Sleep(x) will sleep for ‘x’ milliseconds, but on the Mac the only thing I could find was the unix standard sleep(x) which sleeps for ‘x’ seconds. Can somebody point me in the right direction please?

Also I’m not using the GLUT keyboard interface beause I want access to the Keypad… I’ve gotten one thing to work – “GetKeys”. Is that the best way to get keystates? Also, is there an include or something that describes the keycodes returned for the various keys? (like the letter K is #xxx the letter L is #xxx)

Thanks!

take a look over at macnn.com
they’ve got a nice osx dev section.

actually, it’s not on OS X, but I’ll take a look anyways. Thanks.

Try this out:

void Sleep( int numberOfSeconds )
{

long timeUntilWake = TickCount() + ( numberOfSeconds * 60 )

while( TickCount() < timeUntilWake );
}

TickCount() returns the number of ticks ( 60th of a second ) since system startup.

GetKeys() should return the ascii code for the characters, i.e. ‘K’ and ‘L’. You’d actually have to look up the hex values for keys such as the arrow or function keys though.

Interesting… Yeah, actually, I have found a way to get milliseconds from a counter, so I could just have the program twiddle it’s thumbs till the timer indicates the correct time…

That seems a little strange to do on a system that’s semi-multitasking, but what the heck.

Hopefully, I’ll have my Barrel Patrol game for the Mac soon. I just need to figure out openAL…

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.