image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
LinkBack Thread Tools
  #1  
Old January 21st, 2007, 11:31 AM
Registered User
 
Join Date: Apr 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
y10k is on a distinguished road
need help with setting up GLUT/OpenGL on Mac OS X

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.
Attached Files
File Type: zip monkey.zip (23.4 KB, 10 views)

Last edited by y10k; January 21st, 2007 at 04:41 PM.
Reply With Quote
  #2  
Old January 21st, 2007, 03:27 PM
Registered User
 
Join Date: Sep 2005
Posts: 45
Thanks: 0
Thanked 1 Time in 1 Post
szymczyk is on a distinguished road
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.
__________________
Mark Szymczyk
Author, Xcode Tools Sensei
http://www.meandmark.com
Reply With Quote
  #3  
Old January 21st, 2007, 03:38 PM
Registered User
 
Join Date: Apr 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
y10k is on a distinguished road
Quote:
Originally Posted by szymczyk View Post
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..
Reply With Quote
  #4  
Old January 21st, 2007, 03:42 PM
Registered User
 
Join Date: Apr 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
y10k is on a distinguished road
Quote:
Originally Posted by y10k View Post
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).
Reply With Quote
  #5  
Old January 21st, 2007, 04:06 PM
Mikuro's Avatar
Crotchety UI Nitpicker
 
Join Date: Mar 2005
Posts: 2,719
Thanks: 7
Thanked 60 Times in 54 Posts
Mikuro will become famous soon enough
Try this:

#import <OpenGL/gl.h>
#import <OpenGL/glu.h>
#import <GLUT/glut.h>
__________________
Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8
MacBook Pro — 2.26GHz C2D, 2GB RAM — OS 10.6.3

Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc
Reply With Quote
  #6  
Old January 21st, 2007, 04:23 PM
Registered User
 
Join Date: Apr 2006
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
y10k is on a distinguished road
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?
Reply With Quote
  #7  
Old January 31st, 2007, 06:28 PM
macbri's Avatar
Mac (r)evolution
 
Join Date: Jun 2005
Location: One of these days, Alice....
Posts: 307
Thanks: 3
Thanked 6 Times in 5 Posts
macbri has a spectacular aura aboutmacbri has a spectacular aura about
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
Reply With Quote
  #8  
Old October 29th, 2008, 01:56 PM
Registered User
 
Join Date: Oct 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kangaechigai is on a distinguished road
Quote:
Originally Posted by y10k View Post
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/archi...hp/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.
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -5. The time now is 09:21 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1
Copyright 2000-2010 DigitalCrowd, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52