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?
- How do I define and use an ENUM in Objective-C?
- Calling a Swift function from C++
- How to incorporate WebSockets into a Cocoa application
- Xcode “Thread 1: signal SIGSTOP”
- After writing BMP file, image is flipped upside down
- What happens to a .h file that is not included in a target during compilation?
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…
- How to return an NSMutableArray from an NSSet
- Can iOS do central and peripheral work on same app at same time?
- Cocoa: Simulating Command+Tab in CGEvent
- Is it possible to create a data breakpoint in Xcode?
- “extern const” vs “extern” only
- Image size limitations in mobile safari?
- App architecture when 'state changing' APNS fails
- Ios Numeric keyboard with decimal
- swift_dynamicCastClassUnconditional issues in swift
- Detect current device with UI_USER_INTERFACE_IDIOM() in Swift
- Difference of memory organization between iOS device and iPhone simulator
- ImageView Scaling when scrolling down
- EKEvent eventIdentifier returns null
- jQuery mobile button press event slow to process
- How do I use CATransform3D on a UIView to add a specific type of perspective?