Using OpenGL in Mac OS X

This post has been mostly taken from http://blog.hwrd.me/2014/05/07/beginning-opengl-development-on-os-x/ and a couple other sources.

1. Install Homebrew

Install homebrew from here: http://brew.sh

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 http://macromates.com/download (version 2.0 is beta and open-source).

5. Create sample project and code

Download the sample code from http://blog.hwrd.me/2014/05/07/beginning-opengl-development-on-os-x/, direct link: https://gist.github.com/hahuang65/0c7d14a6fedb221c8b87#file-main-cpp

6. Create Makefile

In the same folder, create a Makefile. If you are unsure what Makefiles are, read: http://mrbook.org/blog/tutorials/make/

Write the Makefile from http://blog.hwrd.me/2014/05/07/beginning-opengl-development-on-os-x/, direct link: https://gist.githubusercontent.com/hahuang65/0c7d14a6fedb221c8b87/raw/25410d0a023fd22c3cdd969afb33707f456dd2f6/Makefile

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>
make

./main

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: http://stackoverflow.com/questions/3315108/makefile-missing-separator