Xcode

Xcode is an integrated development enviroment (IDE), which allows you to write, test, and debug your code. Xcode is available for free for computers running Mac OS X.

Configuring Xcode for OpenGL Development

First, make sure have Xcode installed on your computer.

Create an Empty C++ Project

Xcode has a lot of options and project types. Follow these steps to create an empty C++ project:

  1. From the File menu, hover over New, then select Project.

  2. In the New Project window, navigate to the Mac OS X / Application section. Select the Command Line Tool project type and click Next.

  3. In the Project Options window, enter the name of the project, and make sure the C++ language is selected. Then click Next. You'll then be asked to choose a location to store your project files.

Configure Xcode for OpenGL

Once you are able to create a basic C++ project in Xcode, you'll want to configure it for OpenGL.

  1. Click on the blue project icon on the left side of the window.

  2. Then select the Build Phases section.

  3. Click the triangle next to "Link Binary with Libraries".

  4. Click the plus button, a list of libraries will appear. Scroll down to the OpenGL library, or type "opengl" into the search box. Select the OpenGL Framework and click Add.

  5. Click the plus button again. This time, select the GLUT framework, and click Add.

Keep in mind, that you will need to repeat this step any time you create a new OpenGL project in Xcode.

Testing Your OpenGL Setup

  1. Open your Terminal app.

  2. In the terminal window, create a new directory, then navigate to it.

    mkdir gltest
    cd gltest
  3. Use the scp command to connect to the Linux Lab, and copy all of the files from: /home/cs165new/uiTest into the directory you created. (Replace "lfalin" with your Linux Lab username.

    scp -P 215 -r lfalin@157.201.194.201:/home/cs165new/uiTest/* .
  4. In Xcode, right click the folder containing main.cpp and select "Add Files..."
    Navigate to the folder you created in step 1, and select all of the .h and .cpp files, then click Add.

  5. Since our OpenGL test files already contain a main function, we need to delete the one that Xcode added. To do so, right click main.cpp, select Delete, then click Move to Trash.

  6. To build and run the project, press Command-R, or click the Play button in the toolbar.

If everything went well, you should see a window appear containing a spinning shape, which you can control with the arrow keys.