PDA

View Full Version : new to mac



fathom
06-08-2001, 03:46 PM
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!

jmg
06-08-2001, 08:21 PM
take a look over at macnn.com
they've got a nice osx dev section.

fathom
06-08-2001, 10:47 PM
actually, it's not on OS X, but I'll take a look anyways. Thanks.

Kainsin
06-13-2001, 11:55 AM
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.

fathom
06-14-2001, 10:03 AM
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...