Writing Code
An C/C++ program for Mac OS X should include three header files:
#includeNote that the locations of these header files in Mac OS X differs from where they are in Linux and Windows (e.g., GL/ .h)// Header File For The OpenGL32 Library
#include// Header File For The GLu32 Library
#include// Header File For The Library
Building Using GCC
The command line using GCC to build a program main.c is as follows:
gcc -framework GLUT -framework OpenGL -framework Cocoa main.c -o learningIt is notable here that MacOSX uses the concept of so called frameworks. Instead of adding include paths and library names yourself, you add a framework to your compiler call. This is a MacOSX specific extension to gcc.
Building Using Xcode IDE
We can also manage our OpenGL/GLUT projects using Xcode IDE. To create a project, select the project type of "Cocoa Application". To add/edit the code, remove the auto-generated main.m, add a new main.c, and write our code into main.c. To specify the frameworks in IDE, right click the project and choose "Add Exisiting Frameworks" to add OpenGL and GLUT.
No comments:
Post a Comment