simple opengl program


i'm beginning to read the opengl superbible. the first project just creates a window and renders it blue. on build i get a warning implicit declaration NSApplicationMain. on run i get a bunch of lines that say object released with no pool - just leaking. can anyone tell me what is wrong? here is the code:

#include <GLUT/glut.h>

void display(void)

void setup(void)
glClearColor(0.0f, 0.0f, 1.0f, 1.0f);

int main(int argc, char** argv)
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
return NSApplicationMain(argc, argv);
Your code looks fine to me (except for the include, but I guess this is a problem with the &lt; &gt; :))

I think you have a problem with your project.
Have you added the glut framework and the Open GL framework to your project?
(Project -&gt; add framework)

There is a thread about this around here, "Programming Open GL with Project Builder"
There are some links to some nice online tutorials, where you can also download the tutorials as Project Builder projects.
yes i included both frameworks. i got some of the documentation examples to compile and run like particles.c. this one builds w/o errors just warnings and in the run panel i get all these memory leaks or something. but i dont know why.
Originally posted by tie
By the way, a good place to get working GLUT code is; all his tutorials include projects for MacOS X.
Yes, these are really good examples to learn Open GL.
There's one thing you should know, though:
You have to include the Open GL framework to the projects that you can download there or they won't run. (I think these examples were done on the beta of OS X, and Apple changed quite some things since then).
Also, I could not get any example to run that uses textures. they always crash.
i'm also trying to learn opengl on a mac, mostly under mac os x. like you guys said is a good place for tutorials. i started off doing a simple one like creating a 3d box and rotating it on its x and y axis. when i ran the program, i decided to do a top on my computer, it showed the program i just created was taking like 30 to 40% of the cpu. is that right? how do i optimize it?
Originally posted by mfhaque
the program i just created was taking like 30 to 40% of the cpu. is that right? how do i optimize it?

This usually means that the graphics card, or memory bus, is limiting the performance of your app, not the CPU. So buying a new graphics card will give you a better framerate, and use more CPU time, but buying a new CPU will give you the same framerate. (If it was taking closer to 100% of the CPU, then the opposite would be true.)

The only way to improve performance without upgrading hardware is to optimize the graphics code. Try using display lists and it might go slightly faster. Alternatively, you can think of this as a nice opportunity to waste a lot of CPU time with poor coding, without hurting framerate performance! (Go wild!)

I'm not sure that you really need to worry about optimizing framerates for just rotating a triangle, though. You might even want to limit the framerate to conserve both CPU and graphics card resources.