Programming Open GL with Project Builder

Tigger

Bring mich zum Licht!
Hi,

I just tried to the Tutorial on http://nehe.gamedev.net/opengl1.asp for Mac OS X.

I can compile the app, but I cannot get it running. The compile/run icon turns to the stop-sign, but then nothing happens.
I am new to C programming, and I don't know the Project Builder very well.
I know Java, so I got at least some programming experience.
I think I am doing something wrong with ProjectBuilder.

Can somebody guide me a little?
I think this should be fairly easy, but I am stupid somehow... :(

Thanks for any help :)
 
Could you give some more details? Do you see any red colored output on the build pane of the project builder window when you're building the project? What does it say? I used that tutorial some weeks ago and as far as I remeber it worked fine.
 
It just compiles with no errors, and then nothing happens.
When I double click the app in the finder, it does this programm-pop up thing (The rectangle that zooms to fullscreen), and then nothing. no icon in the dock.
Here is my source, if this helps (tutorial1.c)
Code:
#include <GLUT/glut.h>


#define kWindowWidth	400
#define kWindowHeight	300


GLvoid InitGL(GLvoid);
GLvoid ReSizeGLScene(int Width, int Height);

int DrawGLScene(GLvoid)							// Here's Where We Do All The Drawing
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		// Clear The Screen And The Depth Buffer
	glLoadIdentity();						// Reset The View
        glTranslatef(-1.5f,0.0f,-6.0f);	
        glBegin(GL_TRIANGLES);						// Drawing Using Triangles
        glVertex3f( 0.0f, 1.0f, 0.0f);				// Top
        glVertex3f(-1.0f,-1.0f, 0.0f);				// Bottom Left
        glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right
	glEnd();							// Finished Drawing The Triangle
        return TRUE;							// Keep Going
}


int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
	glutInitWindowSize (400, 300);
	glutInitWindowPosition (100, 100);
	(void)glutCreateWindow (argv[0]);

	InitGL();

	glutDisplayFunc(DrawGLScene);
	glutReshapeFunc(ReSizeGLScene);
	glutMainLoop();

	return 0;
}
 
The functions InitGL and ReSizeGLScene are missing. This code doesn't work unless you have them on another file that's also being linked into the final build product.
 
Thanks for your help!

I made a new Project, because this one didn't even work with a standard Hello World, it just showed me the stop button.

But now, I get the following two errors when I try to compile my Open GL program:

/usr/bin/ld: /Users/tigger/TestProject/Test/build/intermediates/Test.build/master.o illegal reference to symbol: _glBegin defined in indirectly referenced dynamic library /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
/usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib

You said you have done this tutorial. Maybe you could send me your working project, so I can figure out what I have done wrong :)

Email: tigger@dodgethis.de


 
I just copied the GLUT Examples folder in the Developer folder, and put my code in there. It compiled fine, and it also runs fine.

So my problem seems to be that I am too stupid how to create a new Project for Open GL. :)

Can someone give me a step by step explanation on how to create a new project? (Explain it as if I were 6 years old :))
 
Originally posted by Tigger
You said you have done this tutorial. Maybe you could send me your working project, so I can figure out what I have done wrong :)

Sorry... I deleted the project when I was finished with it. Anyway, I get those same errors whenever I try to build a fresh new project that uses OpenGL. So I guess the following will solve the problems you're having now:

/usr/bin/ld: /Users/tigger/TestProject/Test/build/intermediates/Test.build/master.o illegal reference to symbol: _glBegin defined in indirectly referenced dynamic library /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib

You'll have to link with the OpenGL and GLUT libraries. Go to "Project > Add Frameworks..." and select both. Then include them in your target. This should make this line go away.

/usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib

Select your target on the targets pane and add "-lobjc" to your "Other Linker Flags" that is under the "Build Settings" pane of your target settings.

Now it should build the project and run it without any hitches.
 
Originally posted by Tigger
I just copied the GLUT Examples folder in the Developer folder, and put my code in there. It compiled fine, and it also runs fine.

I used to do that too before I learned how to build a new project from scratch. :)


So my problem seems to be that I am too stupid how to create a new Project for Open GL. :)

Are we both very stupid or is there a lack of documentation on how to use OpenGL on MacOSX? I would bet on the second... :D
 
There are many OpenGL Samples i managed to compile and run. On of the best ones i found was at www.oreillynet.com
There are also many many examples in /Developer/Examples/GLUT/ in which i also got to compile and run successfully. I would recommend the oreilly site however.

-whitesaint
 
Thanks Pavao, everything is working now!

Stupid me, I now saw that at the bottom of each page there is a ProjectBuilder project for download.

I can really recommend these tutorials!

http://nehe.gamedev.net/opengl1.asp

I will take a look at the oreilly examples also. Thanks whitesaint!

(It is really nice to see the first own written polygons rotate on the screen :))
 
maybe you can help me too. whenever i try compiling a simple opengl project i get the following linking errors:

/usr/bin/ld: /Users/Zot/Desktop/atest/build/intermediates/atest.build/master.o illegal reference to symbol: _glBegin defined in indirectly referenced dynamic library /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib

/usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib

i'm assuming it has something to do with how i linked the glut framework. i added framework using the default method.
anyone know how to get rid of those errors?
 
Originally posted by zots
maybe you can help me too. whenever i try compiling a simple opengl project i get the following linking errors:

/usr/bin/ld: /Users/Zot/Desktop/atest/build/intermediates/atest.build/master.o illegal reference to symbol: _glBegin defined in indirectly referenced dynamic library /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib

/usr/bin/ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib
Have you also included the Open GL framework?
I think I got the same errors before I included it.
 
Originally posted by Tigger
Stupid me, I now saw that at the bottom of each page there is a ProjectBuilder project for download.

Heh. I wondered what the problem was. Do the projects there still work with the latest ProjectBuilder? They've been around for a while.
 
Originally posted by tie


Heh. I wondered what the problem was. Do the projects there still work with the latest ProjectBuilder? They've been around for a while.
You have to include the Open GL framework, then they will work.
Except for the examples that need to load a texture. They crash every time for me on startup.
 
Originally posted by Tigger

Except for the examples that need to load a texture. They crash every time for me on startup.

I have a similar problem whenever I use fopen. I'm using a bunch of tutorials and I can run them ok using the "Build and Run" command from within project builder. However, when I try to run those same tutorials by double clicking them on the finder, they always crash on fopen because they can't find the file. I did some testing and it seems that when I start them in the finder, the current working directory is the folder where the app is, but sometimes after calling glutInit, the CWD changes to 'previous cwd'/whatever.app. And on some other tutorials it seems that the CWD is the root of the hard disk. I don't understand what's going on so I usually run those things from project builder. Does anyone have a clue?
 
To get the textures to work, you need to make sure they are included in the project: drag the texture files into the left pane of project builder. This copies them inside the .app package/folder (you should delete the entire build folder and rebuild to make sure it works, though). It also sometimes is helpful to make a copy of the textures right inside the build folder, I don't know why.

For my own projects, I just use gltx.c (from a SIGGRAPH a long time ago), and avoid Nehe's messy code.
 
I'm doing opengl programming in school in a Windoze environment. Will the GLUT and OPENGL library and header files that Visual Studio uses work with Project builder? I can't get my project, which compiles with VC++ to compile with the header that i got from the windoze machine.

The error's I'm getting look like:
syntax error before 'void'

for an example of a line with the error:
WINGDIAPI void APIENTRY glRects (GLshort x1, GLshort y1, GLshort x2, GLshort y2);

I can't seem to find where to download the GLUT files from SGI's site. They have a broken link for the page to download the GLUT files.
 
Originally posted by devonferns
I'm doing opengl programming in school in a Windoze environment. Will the GLUT and OPENGL library and header files that Visual Studio uses work with Project builder? I can't get my project, which compiles with VC++ to compile with the header that i got from the windoze machine.
I have the same problem.
VC normally uses gl/glut.h, whereas Mac OS X uses GLUT/glut.h

But you could get around this if you use something like: (Haven't tried tis myself yet, though)

#ifdef _WIN32 //Don't know exactly if "_WIN32" is written like that
   #include <gl/glut.h>
#else
   #include <GLUT/glut.h>
#endif

You have to make sure that your code hasn't any plattform specific parts, though.
Otherwise, you can put these parts also in such #ifdefs, but that can be really complicated.

Here you can find some links to downloads for GLUT:
http://www.opengl.org/developers/documentation/glut/
 
Originally posted by Tigger

I have the same problem.
VC normally uses gl/glut.h, whereas Mac OS X uses GLUT/glut.h

But you could get around this if you use something like: (Haven't tried tis myself yet, though)

#ifdef _WIN32 //Don't know exactly if "_WIN32" is written like that
   #include <gl/glut.h>
#else
   #include <GLUT/glut.h>
#endif

You have to make sure that your code hasn't any plattform specific parts, though.
Otherwise, you can put these parts also in such #ifdefs, but that can be really complicated.

Here you can find some links to downloads for GLUT:
http://www.opengl.org/developers/documentation/glut/

That would work for MY code but the problem I'm having is in the glut header file. It's giving the error that I have above for the line that I wrote above.

Is there a different header for UNIX systems than there is for Windoze systems?
 
Back
Top