Creating a GLUT Project in Xcode
1 Introduction
Xcode is a project-based IDE. That is, it assumes that you are working on
a project of some kind, not an individual class or file. When creating
a project you must specify various properties of the project. This document
describes how to create an Xcode (v 4.6) project that uses OpenGL and GLUT.
2 Steps in the Process
After starting Xcode you should:
- Click on File on the main menu and pull down to
New and Project....
- When you are prompted to "Choose a template" select
"Cocoa Application" and click on Next.
- Enter a "Product Name" (e.g., GLUTtest).
- Uncheck all options (e.g., Uncheck "Use Core Daya",
"Use Automatic reference Counting", "Include Unit Tests", etc...).
- Click on Next.
- Select an appropriate directory/folder for the project
and click on Create.
- Click on the Folder icon near the top left of the window (in case it
isn't already selected).
- Click on the Project icon (e.g., GLUTtest) underneath the
Folder icon (in case it
isn't already selected).
- Delete (i.e., move to the trash) everything from the
main folder (e.g.,
AppDelegate.h
,
AppDelegate.m
, and MainMenu.xib
.
- Delete (i.e., move to the trash) everything from the
"Supporting Files" folder.
- Click on the "Build Settings" tab (in case it isn't already
selected).
- Under "Build Settings", in the "Packaging" section,
make the "Info.plist File" field empty (i.e., select the text in the
field and delete it).
- Under "Build Settings" do one or the other of the following:
- In the "Apple LLVM Compiler" section make the
"Prefix Header" blank.
- In the "User Defined" section make the
"GCC Prefix Header" blank.
Summary - Linked Frameworks and Libraries
Click on the +
Click on Add Other
Navigate to and select /Library/Frameworks/SDL2.framework
Build Settings - Search Paths - Add /Library/Frameworks to the Framework Search Paths
- Click on the "Summary" tab.
- Click on the + in the
"Linked Frameworks and Libraries" section.
- Click on Add Other....
- Navigate to and select
/Library/Frameworks/SDL2.framework
.
- Click on the "Build Settings" tab.
- In the "Search Paths" section enter
/Library/Frameworks
in the "Framework Search Paths" field.
Note that you may want to or need to run SDL on top of OpenGL. In this case,
you will also need to:
- Click on the + in the
"Linked Frameworks and Libraries" section.
- Scroll down to and click on "GLUT.framework".
- Click on Add.
- Click on the + in the
"Linked Frameworks and Libraries" section.
- Scroll down to and click on "OpenGL.framework".
- Click on Add.
3 Testing Your Installation
You can use the following small program (named
test.c
)
to test your installation:
sdlexamples/test.c
Note that you may need to change the #include
directive in this example.
To create a file in your project, click on File on
the main menu and pull down to
New and File..., select the "C File",
and click on Next.
To compile and execute the program, click on Product on
the main menu and pull down to
Run.