On OS X, we're gonna wanna make sure we have Xcode installed. We can get Xcode for free from the Mac App Store. Xcode will install most of the tools we need for this course, except for CMake. We want to use CMake to help us in cross compiling our code and making sure that our project files are pointing to the right libraries. CMake is a great tool for writing code that will work across different platforms. I like building CMake from source, so on the CMake website, let's download the Unix/Linux Source tar files.
Once they are downloaded, cd into the CMake file directory. Here we can type dot slash bootstrap && make && make install. Depending on your user permissions, you may need to write sudo make install. This will build, compile and install the CMake command line tools onto our OS platform. With CMake installed, we can cd into our exercise files folder.
Where we are gonna do here is use CMake to generate an Xcode project file that contains all the lessons for this course. Let's make an Xcode directory, cd into the Xcode directory and type cmake space dash capital G for generate space Xcode in quotes capital X lower-case c o d e space dot dot and hit return.
Cmake is now generating an Xcode project file for us that points to the correct libraries and include header files. If we look inside of our exercise files folder, we see our Xcode directory, and the Xcode project that CMake has generated for us. Let's open that. In our project hierarchy we have all the example files that we're going to be looking at throughout this course. We also have some of the demos that come included with GLFW, the windowing library.
To follow along with the lessons, open the folder that corresponds to the lesson name. In the Source Files directory, we'll find our dot cpp files that correspond to the current lesson. To compile all the current lesson, navigate to the list of targets, select the target and build that. My Xcode project will look a little different. The name of my Xcode project will be at the top of the screen, corresponding to the current lesson.
In the file hierarchy on the left-hand side of the screen, the name of the current lesson also corresponds with the name of the project. So in your Xcode project file, which includes all the lessons in one project file, just make sure that you are in the same folder as the name of the current lesson, and you should be able to follow along.
- What is OpenGL?
- Setting up an OpenGL workflow
- Creating a window with GLFW
- Working with geometric primitives
- Rotating, translating, and scaling
- Understanding matrix transformations
- Creating mesh data structures
- Buffering mesh data
- Getting mouse and keyboard input
Skill Level Intermediate
Q: Why am I getting errors saying I don’t have GLEW installed when I try to create the Xcode projects with Cmake?
1) Download, Install, and Run Xcode
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew install glew
./bootstrap && make && make install
brew install cmake
cd Exercise Filesmkdir xcodecd xcodecmake -G "Xcode" ..