views:

616

answers:

3

Is there any good tutorial or code snippet out there on how to use OpenGL via C/C++ on the iPhone?

+2  A: 

http://developer.apple.com/iphone/library/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html

I'm pretty sure you need a bit of Objective-C to create the context and do other initialization stuff. The rest is also usable in C++.

Axel Gneiting
+3  A: 

In XCode, go to File > New Project... and choose the "OpenGL ES Application" template. That creates a project with great example code for setting up an OpenGL context and drawing into it with the usual C functions. Plus some other neat tricks like loading a UIImage into an OpenGL texture.

Tom
the openGL api is mercifly in C for the iphone.note that you might have a problem putting c++ in one of those files in that template. it might be set up to work only with c, not c++. if it is, right click on the file in the solution explorer in xcode, go Get Info->General tab->File Type and set it to 'sourcecode.cpp.objcpp'
matt
@matt: or simply rename the cpp-file-extension to .mm
Till
+2  A: 

The author of "Beginning iPhone Development" has a number of iPhone OpenGL tutorials on his blog. Additionally, he provides a template project for OpenGL in his first tutorial. Some Objective-C is required to work with OpenGL on the iPhone.

Chris Ridgway