Installing OpenGL and GLUT on a Mac?

Does anyone know how exactly I’d do this? I’ve been reading up, and everything seems to point to the apple website. I’ve downloaded what people said to download, but it doesn’t seem to have anything I can actually INSTALL with, just things that I’m supposed to install somehow. Try as I might, I haven’t been able to find a guide that actually explains how I’m supposed to get it all working. Does anyone know?

Thanks,
Spidy

I program opengl on my powerbook and it required no setup… opengl & glut are already installed with the operating system… you just need to include it in your projects.

According to the tutorial I’ve been working with, all I had to include was

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include "tk.h"  

But that doesn’t seem to work. Do I have to compile it some special way or something? Termain commands like “which glut” and “which opengl” return nothing, so I’m not 100% sure they’re already installed.

When I try to compile code with those includes, it throws an error about the files I’m including not existing.

Spidy

I believe you used a windows guide.

change that to say
#include <GLUT/glut.h> // thats it

And in xcode you need to set up a package to include OpenGL.framework and GLUT.framework
Right-click the project file in xcode and click add frameworks… and browse to them

Yes, you do not need those other headers you previously posted (gl.h, glu.h).

And when you are creating an Xcode project, the easiest way to do it is create an empty project, add a Carbon target, add all your source code files, then add the frameworks “Cocoa”, “GLUT”, and “OpenGL”, and then you’re set to go!

Also, you can follow the NeHe tutorial found on my website (once you’ve done that, you can move right on to NeHe lesson 2):
http://dhost.info/joetheprogrammer/wordpress/?page_id=47
(sometimes it’s down because of excess traffic, so if that happens, try again later)

it was a NeHe tutorial in the first place…must have clicked the wrong one. I’m using Smultron for my editing though, is there anything different I need to do because of that?

Spidy

Sorry for the double post, but I’ve edited the file and tried compiling, only to get these errors:

/usr/bin/ld: Undefined symbols:
DrawGLScene()
ReSizeGLScene(int, int)
InitGL()
_glutCreateWindow
_glutDisplayFunc
_glutInit
_glutInitDisplayMode
_glutInitWindowPosition
_glutInitWindowSize
_glutMainLoop
_glutReshapeFunc
collect2: ld returned 1 exit status
  

I don’t know DrawGLScene() to be a function of OpenGL… that’s something you need to define… (i could be wrong on that)

int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);
glutInitWindowSize (1024, 640);
glutInitWindowPosition (100, 100);
glutCreateWindow ("jamesonquave.com");
glutFullScreen();
init();
createLights();
glutDisplayFunc (display);
glutIdleFunc (display);
glutReshapeFunc (reshape);
glutMainLoop ();
return 0;
}

After changing the main() block to what you suggested, it threw these errors:

 test.cpp: In function 'int main(int, char**)':
test.cpp:24: error: 'init' was not declared in this scope
test.cpp:25: error: 'createLights' was not declared in this scope
test.cpp:26: error: 'display' was not declared in this scope
test.cpp:28: error: 'reshape' was not declared in this scope 

again, those are functions that you have to write yourself… i cant write the entire program for you… thats just a skeleton…
init, createLights, display, and reshape are all things that you need to write somewhere else… (createLights is optional)

After messing around with it for a while, I’ve still managed to get it to throw these errors:

 /usr/bin/ld: Undefined symbols:
_glClear
_glClearColor
_glClearDepth
_glDepthFunc
_glEnable
_glLoadIdentity
_glMatrixMode
_glShadeModel
_glViewport
_gluPerspective
_glutCreateWindow
_glutDestroyWindow
_glutDisplayFunc
_glutFullScreen
_glutIdleFunc
_glutInit
_glutInitDisplayMode
_glutInitWindowPosition
_glutInitWindowSize
_glutKeyboardFunc
_glutMainLoop
_glutReshapeFunc
_glutSwapBuffers
collect2: ld returned 1 exit status 

It seems to throw them when all the other code is correct, as a parting shot or something.

Spidy

That means that everything is now compiling. You need to add ‘-framework OpenGL -framework GLUT’ to your compile command to allow the linker to find those functions.

That’s solved the problem. Thanks!