Xcode OpenGL GLUT help please!
Hey guys this is my first time posting here! Anyway I'm having trouble getting a simple graphics program to run on my powerbook.
I am trying to use Xcode in order to get a graphics program that utilizes OpenGl and Glut. I have to do this for a project for one of my classes so I'm constrained to Glut.
Anyway I set up a project with xcode following the guidelines from the link below:
http://www.vis.uky.edu/~dnister/Teaching...Notes.html
This was very helpful as when I tried to make an empty project and put everything together I wasn't getting any executables even though it would compile with no errors. Is there a reason for this specifically? My guess is that my main was not compiling against the header files in the frameworks even though I included them specifically in my header file.
Well after setting up this project I added my code and updated the header file but now when I click on compile and run I get "Undefine Symbols - glutCreateWindow -glutDisplayFunction" etc. Now I am pretty sure I'm including all of the correct frameworks and i'm including all of the header files correctly so I'm not sure why I'm getting these problems.
Out of sheer frustration I decided to include every header file in the frameworks and then I get the error "error 'cgl_ctx' not defined in this scope".
To give you guys an idea I include the openGl and the glut frameworks and imported all the header files from there.
I'm really confused on this and I would appreciate any help or information on this. I started writing this program on a friend's laptop using dev and it was working there but are there mac specific calls for Glut? That doesn't make sense to me because it's supposed to be platform independent. Oh well let me know whatever you can.
My header file is:
My code is
I am trying to use Xcode in order to get a graphics program that utilizes OpenGl and Glut. I have to do this for a project for one of my classes so I'm constrained to Glut.
Anyway I set up a project with xcode following the guidelines from the link below:
http://www.vis.uky.edu/~dnister/Teaching...Notes.html
This was very helpful as when I tried to make an empty project and put everything together I wasn't getting any executables even though it would compile with no errors. Is there a reason for this specifically? My guess is that my main was not compiling against the header files in the frameworks even though I included them specifically in my header file.
Well after setting up this project I added my code and updated the header file but now when I click on compile and run I get "Undefine Symbols - glutCreateWindow -glutDisplayFunction" etc. Now I am pretty sure I'm including all of the correct frameworks and i'm including all of the header files correctly so I'm not sure why I'm getting these problems.
Out of sheer frustration I decided to include every header file in the frameworks and then I get the error "error 'cgl_ctx' not defined in this scope".
To give you guys an idea I include the openGl and the glut frameworks and imported all the header files from there.
I'm really confused on this and I would appreciate any help or information on this. I started writing this program on a friend's laptop using dev and it was working there but are there mac specific calls for Glut? That doesn't make sense to me because it's supposed to be platform independent. Oh well let me know whatever you can.
My header file is:
Code:
#include <stdlib.h>
#include "time.h"
#include <Carbon/Carbon.h>
#include <GLUT/glut.h>
#include <GLUT/gutil.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <OpenGL/OpenGL.h>
//All header files from the frameworks
#include <GLUT/copy.h>
#include <GLUT/extrude.h>
#include <GLUT/glsmap.h>
#include <GLUT/glsmapint.h>
#include <GLUT/glutbitmap.h>
#include <GLUT/glutf90.h>
#include <GLUT/glutstroke.h>
#include <GLUT/intersect.h>
#include <GLUT/port.h>
#include <GLUT/rot.h>
#include <GLUT/segment.h>
#include <GLUT/tube.h>
#include <GLUT/tube_gc.h>
#include <GLUT/vvector.h>
#include <OpenGL/gluContext.h>
#include <OpenGL/gluMacro.h>
#include <OpenGL/gliDispatch.h>
#include <OpenGL/gliContext.h>
#include <OpenGL/glext.h>
#include <OpenGL/CGLTypes.h>
#include <OpenGL/CGLRenderers.h>
#include <OpenGL/CGLProfiler.h>
#include <OpenGL/CGLMacro.h>
#include <OpenGL/CGLCurrent.h>
#include <OpenGL/CGLContext.h>My code is
Code:
# include "main.h"
void resize(int w, int h){
glViewport(0, 0, (GLsizei) w, (GLsizei) h); //reset viewport to the new dimensions
glMatrixMode(GL_PROJECTION); //set projection matrix to current matrix
glLoadIdentity(); //reset projection matrix
gluPerspective(54.0f, (GLfloat)w/(GLfloat)h, 1.0f, 100.0f); //calculate aspect ratio
glMatrixMode(GL_MODELVIEW); //set model view matrix
glLoadIdentity();
}
float testx;
float testy;
int timeWait;
void display(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glClearColor(1,1,1,1);
gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
timeWait;
timeWait = glutGet(GLUT_ELAPSED_TIME);
testy = .5;
glPushMatrix();
glColor3f(1.0, 1.0, 0.0);
glTranslated(testx, testy, 0);
glutSolidSphere(1, 32, 32);
glPopMatrix();
glClearColor(1,1,1,1);
if(timeWait < 1000)
testx = testx + .01;
else if(timeWait < 2000)
testx = testx - .01;
glutSwapBuffers();
}
void idle(void){
glutPostRedisplay();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(10,10);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow("FreeGLUT Shapes");
testx = 0;
glutReshapeFunc(resize);
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
return EXIT_SUCCESS;
}
Thanks for your help but when I do as the tuorial says I get the following error message.
"error: 'NX_TABLET_POINTER_UNKNOWN' undeclared here (not in a function)"
I get 6 other ones like this. I think it has something to do with Carbon.framework not being in that location. What do you think? Let me know
"error: 'NX_TABLET_POINTER_UNKNOWN' undeclared here (not in a function)"
I get 6 other ones like this. I think it has something to do with Carbon.framework not being in that location. What do you think? Let me know
I have never heard of anyone getting that error. Are you sure you have the developer tools installed correctly? Which OS and Xcode version are you using?
Operating System is OS X 10.4.7
Xcode is 2.2.1
I found out that when I add a Carbon Target it will automatically compile the Carbon Framework. When it would do this it would try to access a header file named "Ink.h" my computer's type wasn't listed so it would give me that error message. I went into the header file and commented out the code that calls this and now i just get the error of Undeclared Symbol glutinit(). I have a very simple c program that just calls glutinit.
I am including the GLUT framework in the project and linked it with the binary files and it still cannot find this function call. I looked at the GLUT.framework and there are only header files. There is no definition of the function unless it is in a file simply named GLUT. I'm not sure about this though.
Thanks for the help. Any ideas?
Xcode is 2.2.1
I found out that when I add a Carbon Target it will automatically compile the Carbon Framework. When it would do this it would try to access a header file named "Ink.h" my computer's type wasn't listed so it would give me that error message. I went into the header file and commented out the code that calls this and now i just get the error of Undeclared Symbol glutinit(). I have a very simple c program that just calls glutinit.
I am including the GLUT framework in the project and linked it with the binary files and it still cannot find this function call. I looked at the GLUT.framework and there are only header files. There is no definition of the function unless it is in a file simply named GLUT. I'm not sure about this though.
Thanks for the help. Any ideas?
If you're getting errors about undefined glutInit, you haven't linked the GLUT framework successfully. (And yes, the file just called GLUT is where the code is).
How do you properly link a framework? I thought you just had to add the framework to the link binary with files section under your target. Once you've done this you shoud have the library linked no?
Just adding the framework to your project should be sufficient. Follow the tutorial
Ok guys the framework is added correctly but it still wouldn't compile so I finally cracked and went to the shell in order to compile my program. It will run by simply
running the compile command with all of the frameworks imported.
g++ -framework OpenGL -framework GLUT main.cpp -o blah
In short I really don't get why it's not compiling the frameworks inside of xcode when they are perfectly fine.
For now I've been working from the shell but I'm really confused as to why it's not working with xcode. I had another powerbook owner from my class take a look at what I was doing and he was also quite stumped. Just wondering if you have any ideas. If not thanks for all your help seriously!!
running the compile command with all of the frameworks imported.
g++ -framework OpenGL -framework GLUT main.cpp -o blah
In short I really don't get why it's not compiling the frameworks inside of xcode when they are perfectly fine.
For now I've been working from the shell but I'm really confused as to why it's not working with xcode. I had another powerbook owner from my class take a look at what I was doing and he was also quite stumped. Just wondering if you have any ideas. If not thanks for all your help seriously!!
Hello fellow El Pasoan!
I tested OSC's tutorial with the same system and Xcode 2.3 (which shouldn't make any difference), and it works just fine. The only discrepancy that I noticed is that it should now be "Add to Project..." from the Project menu, instead of "Add Frameworks...". Also, I don't recall Xcode *ever* opening me up in the /System/Library/Frameworks/ directory. Try starting a new project and following the directions exactly. If it still doesn't work, then it is possible that your developer tools may need to be reinstalled.
I tested OSC's tutorial with the same system and Xcode 2.3 (which shouldn't make any difference), and it works just fine. The only discrepancy that I noticed is that it should now be "Add to Project..." from the Project menu, instead of "Add Frameworks...". Also, I don't recall Xcode *ever* opening me up in the /System/Library/Frameworks/ directory. Try starting a new project and following the directions exactly. If it still doesn't work, then it is possible that your developer tools may need to be reinstalled.
Hey guys great news!! I got it to work with Xcode. I slept on it and left it alone for awhile and I figured out why it wasn't working.
This was seriously a stupid human error. After compiling time after time I realized that I was always getting 2 constant warnings. Basically the warnings were telling me that the Mac OS x 10.3.9.sdk file was incompatible with my computer based on some arch. flags. Basically all I had to do was to go in and change the framework path for the target to the 10.4u.sdk for my mac and voila!! IT WORKS!! FINALLY!!
Well I'll tell you what I learned A LOT from this so now I can get started on it.
Thanks for your help OneSadCookie and AnotherJake!! I really appreciate it! See you guys around.
This was seriously a stupid human error. After compiling time after time I realized that I was always getting 2 constant warnings. Basically the warnings were telling me that the Mac OS x 10.3.9.sdk file was incompatible with my computer based on some arch. flags. Basically all I had to do was to go in and change the framework path for the target to the 10.4u.sdk for my mac and voila!! IT WORKS!! FINALLY!!
Well I'll tell you what I learned A LOT from this so now I can get started on it.
Thanks for your help OneSadCookie and AnotherJake!! I really appreciate it! See you guys around.
I recently followed your tutorial to the T and i am getting this error after build and go.
OpenGL_Practice has exited with status 1.
[Session started at 2006-09-23 19:38:45 -0400.]
2006-09-23 19:38:45.664 OpenGL_Practice[779] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow
Please help. I have a project due and I cant find jack on this error
best,
Jorry
OpenGL_Practice has exited with status 1.
[Session started at 2006-09-23 19:38:45 -0400.]
2006-09-23 19:38:45.664 OpenGL_Practice[779] GLUT Fatal Error: internal error: NSInternalInconsistencyException, reason: Error (1002) creating CGSWindow
Please help. I have a project due and I cant find jack on this error
best,
Jorry
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| OpenGL and GLUT on MacOSX | Salvietta | 1 | 2,033 |
Sep 19, 2008 12:03 PM Last Post: OneSadCookie |
|
| Dealing with GLUT and OpenGL... | RingoEST | 10 | 4,935 |
Aug 16, 2008 12:24 AM Last Post: RingoEST |
|
| Xcode OpenGL Application Template | GryphonClaw | 19 | 9,369 |
Dec 31, 2004 11:09 AM Last Post: ThemsAllTook |
|
| OpenGL Setup Without GLUT | Justin Brimm | 3 | 3,456 |
Jan 25, 2004 11:44 PM Last Post: skyhawk |
|
| Which dylib in OpenGL framework gets linked? (simple glut ex) | johnMG | 6 | 3,251 |
Oct 22, 2003 06:06 AM Last Post: anarchie |
|

