Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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?

like image 653
Eric Thoma Avatar asked Jan 03 '12 03:01

Eric Thoma


1 Answers

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++.

like image 112
Miguel Avatar answered Sep 25 '22 21:09

Miguel