NeHe Productions: OpenGL Lesson #Mac_OSDate de publication : 31/03/2006 , Date de mise à jour : 31/03/2006
Par
Tony Parker ( asp@usc.edu ) (Autres articles)
Lesson: Mac OS So you've been wanting to setup OpenGL on Mac OS? Here's the place to learn what you need and how you need
to do it.
What You'll Need:
First and foremost, you'll need a compiler. By far the best and most popular on the Macintosh is
Metrowerks Codewarrior (www.metrowerks.com). If you're a student, get the educational
version - there's no difference between it and the professional version and it'll cost you a lot less.
Next, you'll need the OpenGL SDK (developer.apple.com/opengl/) from Apple. Now we're ready to
create an OpenGL program!
Getting Started with GLUT:
Ok, here is the beginning of the program, where we include headers:
The first is the standard OpenGL calls, the other three provide additional calls which we will use in our
programs.
Next, we define some constants:
We use these for the height and width of our window. Next, the function prototypes:
... and the main() function:
glutInit(), glutInitDisplayMode(), glutInitWindowSize(), glutInitWindowPosition(), and glutCreateWindow()
all set up our OpenGL program. InitGL() does the same thing in the Mac program as in the Windows program.
glutDisplayFunc(DrawGLScene) tells GLUT that we want the DrawGLScene function to be used when we want to
draw the scene. glutReshapeFunc(ReSizeGLScene) tells GLUT that we want the ReSizeGLScene function to be
used if the window is resized.
Later, we will use glutKeyboardFunc(), which tells GLUT which function we want to use when a key is
pressed, and glutIdleFunc() which tells GLUT which function it will call repeatedly (we'll use it to spin
stuff in space).
Finally, glutMainLoop() starts the program. Once this is called, it will only return to the main() function
when the program is quitting.
You're done!
Well, that's about it. Most everything else is the same as NeHe's examples. I suggest you look at the
Read Me included with the Mac OS ports, as it has more detail on specific changes from the examples
themselves.
Have fun!
Tony Parker ( asp@usc.edu )
|
Les sources présentées sur cette page sont libres de droits et vous pouvez les utiliser à votre convenance. Par contre, la page de présentation constitue une œuvre intellectuelle protégée par les droits d'auteur. Copyright © 2006 Nehe Gamedev.net. Aucune reproduction, même partielle, ne peut être faite de ce site ni de l'ensemble de son contenu : textes, documents, images, etc. sans l'autorisation expresse de l'auteur. Sinon vous encourez selon la loi jusqu'à trois ans de prison et jusqu'à 300 000 € de dommages et intérêts.