Notes on OpenGL & GLUT in Xcode

Notes on OpenGL & GLUT in Xcode

NOTEs:
Run Xcode

MAKE A NEW OpenGL PROJECT

SELECT: File->new project
SELECT: empty project

Type in  (e.g. 'lab0Project')
'Choose' (browse to) directory where you want the project; in my case, it's
  Programming->Xcode

CLICK: Finish

SELECT: project->new target
SELECT: carbon:application
CLICK: Next
type in  (e.g. 'lab0')
CLICK: Finish

Under 'Group & Files', SELECT:   (e.g. lab0Project)
SELECT: project->add to project
BROWSE TO: Maintosh HD->System->Library->Frameworks
CLICK: cocao
CMD-CLICK: glut
CMD-CLICK: opengl
CLICK: ADD (the radio button 'Recursively create ...' should be already selected; if not, select it

ADD & ORGANIZE SOURCE CODE


Make some Xcode 'groups' to put frameworks and your source code in
Under 'Group & Files', SELECT 
SELECT File->new group
NAME IT:  Frameworks
Move the frameworks you just added to this group to set them out of the way

Now make a group for the sources files for this specific project
Under 'Group & Files', SELECT 
SELECT File->new group
NAME IT: Sources

In the project directory, create a main.c file
Add it to the project in the Xcode 'Sources' group:
SELECT: Project->Add to Project
browse to the project directory where main.c is and select it
CLICK: Add
CLICK: Add (with the 'Recursive' radio button on as before)
It will appear in the list on the left of the Xcode window
 it appears outside of the Sources group, move it there

For later labs, you might also want a group for common support routines.
In my programming directory, I have a 'Support' folder where I put commonly 
used routines. For example, have  matrix.c, material.c, and geometry.c 
files in my 'Support' folder.
To include other source files, make a group in Xcode and add the files to it:
Under 'Group & Files', SELECT 
SELECT File->new group
NAME IT: Support
add source files from Support folder as you did with main.c
However, you have to to tell Xcode where to find the header files for 
these other files:
Add a source path by SELECT: Project->Edit Project Settings
DOUBLE CLICK: User header search paths 
and add a relative path
e.g. ../../Support

INCLUDE HEADERS

In main.c, use:

#include <GLUT/glut.h>
#include <stdlib.h>
#include <math.h>
...

CMD-R will compile and run the program

NOTES

8/28/07
glutInit seems to interfere with file I/O. I can do file I/O before 
glInit(), but afterward and nothing happens file-wise.