Lesson 0b: Getting OpenGL Set Up on Mac OS X

Getting OpenGL and GLUT Set Up

Setting up OpenGL and GLUT on Mac OS X is really easy. Just make sure you've installed the special developer programs, which should have come on your computer's recovery / install CD. That's it!

Compiling and Running the Test Program

Let's make sure that OpenGL works. Download the source code for this later lesson and extract it to any folder (e.g. using Finder). Then, from the command-line, use "cd" to change to the directory where you extracted it. Enter "make" to compile the program, and make sure there are no error messages. Then, enter "./cube" to run the program, and make sure that it runs. Press ESC to exit the program when you're done.

Compiling and Editing

To my knowledge, the standard way of editing and compiling a C++ program in Mac is to edit it with a text editor, such as TextEdit, or Emacs or Vim for advanced users, and compiling it using the "make" command like in the previous section. (Unfortunately, I don't know of any better text editors out there for Mac.)


Look at the contents of "Makefile" in the source directory. It is an important file used by "make" to figure out how to compile our program. The line "PROG = cube" tells "make" that we want the executable file to be called "cube". The line "SRCS = main.cpp imageloader.cpp" tells "make" the files that we need it to compile. You'll have to edit these lines if you ever want to change the name of the executable or change the source files that "make" compiles.

Next is "Part 1: The Basics".