How do I set up an OpenGL project using XCode 4.2 in C++?

I am trying to get in to some graphics in C++. I figured it was best to start with the most capable graphics framework so I am going with the OpenGL included in Lion.

Basically I started a command line tool in C++ in XCode 4.2 and that’s all I have done.

  • Resumable assert/breakpoint on iOS like __debugbreak() with MS compiler
  • Why dereferencing a NSString pointer is not necessary?
  • OpenCV HoughCircles
  • XCode automatically deactivating breakpoints
  • C# application on Apple IOS
  • How to link glew in xcode
  • I need to somehow link OpenGL with the XCode so I can use it. After I get it set up on my Mac platform, I hope I can use a basic how-to guide for OpenGL for C++ to get further as, if you haven’t noticed, I am not entirely clear on how to precede. Pretty much all I have read is some background information on how OpenGL uses the CPU and GPU together with the OpenGL client and server. I would appreciate any guide recommendations as well.

    The question is: how do I link OpenGL with XCode 4.2 in C++ (not objective-c, it’s funky) so I can use the graphics capabilities?

    2 Solutions Collect From Internet About “How do I set up an OpenGL project using XCode 4.2 in C++?”

    To use OpenGL in XCode you have to add the OpenGL framework to your project. Once that is done the header and library files will be available to the compiler and linker.

    This page has a step by step tutorial for creating a C project that uses OpenGL and GLUT. If you are starting with OpenGL, then using GLUT might be a good idea, by the way. The tutorial will tell you to create a main.c file at some point. Instead, you have to create a main.cpp if you want to use C++.

    If you don’t want to go the GLUT route just setup all your window and your base openGL context etc from objective C, then make calls to C++ functions from objective-C. You’ll then be using objective-C++ which is fine. All you need do is name the objective-C++ bridge files with .mm, name any pure objective-C files with .m and your C++ implementation files .cpp and XCode should be happy.

    As mentioned by Miguel, you’ll still need to add the OpenGL framework to your project though…