Using OpenGL in Mac OS X

This post has been mostly taken from and a couple other sources.

1. Install Homebrew

Install homebrew from here:

2. Install GLFW3

Once that is installed, install GLFW3 like so:

# Tap into homebrew/versions where GLFW3 lives
brew tap homebrew/versions

# Install it
brew install glfw3

3. Install Glew

Glew is used to allow your programs direct access to some OpenGL commands without having to go through Mac OS X system calls.

Using Homebrew, install like so:

brew install glew

4. Install TextMate

You can also use CLion or even XCode if you wish to fight them when creating your builds. I've tried using CLion but gave up since they only support CMake.

If not, use something like TextMate, Sublime, or vim.

Download TextMate from (version 2.0 is beta and open-source).

5. Create sample project and code

Download the sample code from, direct link:

6. Create Makefile

In the same folder, create a Makefile. If you are unsure what Makefiles are, read:

Write the Makefile from, direct link:

7. Compile and run

Then simply go to your terminal, navigate to the appropriate directory (where your Makefile and sample code live), and compile using make:

cd <directory>


If you get an error when compiling (missing separator), then make sure tabs are used instead of spaces when indenting the very last line in the Makefile provided: