Vladyslav Semenchenko
Vladyslav Semenchenko

Reputation: 625

Clean C++ OpenGL for iOS

Can I use clean c++ version of openGL in my iOS App? I want write some basic wrapper, then connect my code in c++ with this wrapper and App. Or I must use only openGLES? With GLKit. Describe me all variants.

Upvotes: 1

Views: 1620

Answers (2)

Kazuki Sakamoto
Kazuki Sakamoto

Reputation: 13999

iOS doesn't support OpenGL at all. You must use OpenGL ES for iOS devices.

You can use OpenGL ES 1.1 and 2.0 on every single iOS devices (actually you can use only OpenGL ES 1.1 on iPhone 3G, however recent iOS doesn't support iPhone 3G at all).

Also you can use OpenGL ES 3.0 on Apple A7 and A8 GPU devices, such as iPhone 6.

See the Apple document for more details.

All you need to use OpenGL ES on iOS, is CAEAGLLayer and EAGLContext. GLKit is just a useful wrapper classes for those classes.

After setting up those classes, you can use OpenGL ES API as the other environment.

By the way, this project https://code.google.com/p/gl-wes-v2/ provides some OpenGL 2.0 APIs on OpenGL ES 2.0 environment. It seems it isn't compatible with iOS, but you might be able to use some code from the project.

Upvotes: 1

Tommy
Tommy

Reputation: 100622

iOS supports OpenGL ES only. Currently supported devices are exclusively 2.0 and 3.0, which are both programmable pipelines; older devices were 1.1 which was the fixed pipeline.

ES is integrated as the Core Animation level. Prior to GLKit you were required to create a layer — the simplest thing that the compositor can display — and build that into a view hierarchy. CADisplayLink is the 3.0+ way of tying in to the device's [virtual] horizontal sync.

GLKit is separate and aims to:

  • provide easy view-level wrappings, creating and tying together a GL context, a layer, a view and a display link;
  • provide shaders equivalent to the old fixed-functionality pipeline so that ES 2.0+ can be used just as easily as 1.1 was for the same set of purposes.

It's up to you whether you use it.

One of the languages supported by LLVM is Objective-C++. That's C++ and Objective-C code intermingled, each able to call the other. You could easily create a single Objective-C++ file that exposes an ordinary C++ class for all of the rest of your ordinary C++ code but which internally makes appropriate calls to bridge into the Objective-C world. So you'd probably have a few hundred lines of Objective-C dealing with the OS stuff and exposing stuff you care about for C++ actors.

Upvotes: 3

Related Questions