Here, we'll take a look at how to set up OpenGL using SDL on a Mac system. We'll begin by downloading the essential libraries on your system. As seen in the previous sections, we'll be using Homebrew to download the packages and libraries.
In the Terminal, type the following command to download and install the SDL libraries:
brew install sdl2
Now, just press Enter and the SDL library will be downloaded onto your system. Next, we'll download the GLEW library, but since we've already downloaded it in the previous section, you can refer to that. If you want a quick review on downloading GLEW, you can refer to the Downloading the GLFW and GLEW libraries for a Mac section.
Follow these steps:
Details of the project
- Then, set the location where you would like to store and save the project, and then click on the
Create
button.
- Next, click on your project and go to
Build Settings
. InBuild Settings
, go to theSearch Paths
section and click onHeader Search Paths
. Then, click on+
and type/usr/local/include
. This will allow us to #include GLEW and SDL header files in ourmain.cpp
. - Now go to
Build Phases
, then click onLink Binary With Libraries
, and click the+
button. Typeopengl
in the search bar, selectOpenGL.framework
, and then click on theAdd
button. - Again click on the
+
button, and then click onAdd Other...
. Now, press Cmd + Shift + G, and it will open up ago-to
folder search bar. In it, type/usr/local
. Then click onCellar
, go to theglew
|lib
folder, selectlibGLEW.1.12.0.dylib
without the little arrow, and click onOpen.
- Click
+
again, then clickAdd Other....
Press Cmd + Shift + G and type/usr/local
. Now go toCellar
, and go tosdl | lib
. Select the non-aliaslibSDL2-2.0.0.dylib
and click on theOpen
button.
With all the steps executed, our project is now set up to use SDL and GLEW with OpenGL on a Mac. We can now go to the main.cpp
file and start writing our code for creating the OpenGL rendering window.