OpenGL on MacOS X

Started by
2 comments, last by MARS_999 18 years, 4 months ago
Hi! I have already asked something about this topic last week. Somebody postet a link to an Apple example project. This example worked well, but it was too complicated. I didn't want to see how to work with OpenGL, but I just want to get OpenGL started. I do already know how to use the API, my problem is just that I do not know how to create an OpenGL window with Carbon. In the meantime I have written a test project. It initializes OpenGL (it sets the pixel format and such things. I think this part of the project is correct, since I copied it from a tutorial). But now I have troubles with my event loop. I have written the following code:

bool running = true;
while  (running){
   glClearColor(1.0,0.0,0.0,0.0);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   aglSwapBuffers (context);

   ReceiveNextEvent(0, NULL,kEventDurationNoWait,true, &theEvent);
   SendEventToEventTarget (theEvent, theTarget);
   ReleaseEvent(theEvent);
}
I just wanted to render an empty scene with a red background while the program should still process events from the event loop. But the code above does not work very well. When I start the program I see an empty window at first. After about 10 seconds the window gets a red background. This is exactly what I expected, it just takes too long. Additionally, the program makes my whole system very slow. But I don't know what I made wrong: the loop should render the frames as fast as possible. Does anybody have an idea? Thanks in advance. rgds.
Advertisement
This is a question about Carbon, and not about OpenGL. A more appropriate place to ask this question would be the Carbon-dev mailing list at http://lists.apple.com.
Nehe has a Objective C, Xcode example. If you use glut you can do it in c or c++ really easy. I am fairly new to OSX programming and from what i can tell Carbon is dying...correct me if i am wrong.




-Jacob
Jacob Hammackhttp://www.hammackj.com
Quote:Original post by hammackj
Nehe has a Objective C, Xcode example. If you use glut you can do it in c or c++ really easy. I am fairly new to OSX programming and from what i can tell Carbon is dying...correct me if i am wrong.




-Jacob


Carbon isn't dead but you might as well get used to using Cocoa on Mac for its Apples baby and might have more support or updates than Carbon for Carbon was made to help move OS9 apps to OSX faster than recoding them all. Cocoa really is nice to use and to setup OpenGL is easy with Cocoa. Making a editor in IB with Cocoa is like butter...

This topic is closed to new replies.

Advertisement