need help with setting up GLUT/OpenGL on Mac OS X

y10k

Registered
I am taking a computer graphics course this semester and the assignments are designed to work on Linux and Windows.

I am wondering if it is possible to compile this on Mac OS X.

Attached is the assignment files, including a GLUI include files.

Any clue how I can compile this on Mac?

---------------

updated:

I have compiled the program. However, when I runned it the following errors were showed:



[Session started at 2007-01-21 17:21:55 -0500.]
Usage: demo [width] [height]
Using 300x200 window by default...
2007-01-21 17:21:56.027 monkey[2314] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow


After Google I suspect this is because the cocoa layer is not initialized and can probably be solved by adding NSApplicationLoad.

I don't know how I can add that function since this is the first time I program on Mac.
 

Attachments

  • monkey.zip
    23.4 KB · Views: 11
Create a C++ Tool project (or Standard Tool project if you're using C instead of C++) in Xcode. Add the OpenGL and GLUT frameworks to your project. That should be enough to compile GLUT code on Mac OS X.
 
Create a C++ Tool project (or Standard Tool project if you're using C instead of C++) in Xcode. Add the OpenGL and GLUT frameworks to your project. That should be enough to compile GLUT code on Mac OS X.


How should I change the include files?

#include <GL/gl.h>

#include <GL/glu.h>

#include <GL/glut.h>

It shows

error: GL/gl.h: No such file or directory
error: GL/glu.h: No such file or directory
etc..
 
How should I change the include files?

#include <GL/gl.h>

#include <GL/glu.h>

#include <GL/glut.h>

It shows

error: GL/gl.h: No such file or directory
error: GL/glu.h: No such file or directory
etc..


It compiled after I changed all the include <GL/...> to include <GLUT/...>

However, when I runned the program, it showed:

[Session started at 2007-01-21 16:41:47 -0500.]
ZeroLink: unknown symbol '_GLUI_Master'

monkey has exited due to signal 6 (SIGABRT).
 
After lots of tweaking, I can compiile the program now.

However, when it runs, it shows:

[Session started at 2007-01-21 17:21:55 -0500.]
Usage: demo [width] [height]
Using 300x200 window by default...
2007-01-21 17:21:56.027 monkey[2314] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow


How can I resolve this problem?
 
I used Fink to install glut and glui packages:

Code:
fink install glut glut-shlibs glui glui-shlibs

Then I edited monkey.cpp similar to Mikuro's suggestion :

Code:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#include <glui.h>
and the Makefile to search /sw/include and /sw/lib for headers and libraries respectively (which is where Fink installs stuff):

Code:
CPPFLAGS      = -I/sw/include
GL_LIBS       = -L/sw/lib -lGLU -lGL -lglut -lglui

It compiled with some warnings but otherwise ok. Ran fine from an Xterm and I even captured the 'proof' for ya :)

monkey_main.pngmonkey_control.png
 
GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow

When I had this error, I found one potential solution at http://www.idevgames.com/forum/archive/index.php/t-6635.html. Apparently
Code:
glutInit(&argc, argv);
must be called in your main before you can create a window, but this seems not to be necessary on many other platforms, so it's left out of a lot of sample code.
 
Back
Top