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

送分小仙女□ 提交于 2019-12-04 08:31:14

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!