Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-platform development with GLKit?

I've just installed the current Xcode 4 release and realized the new "GLKit" API thats also used in the OpenGL Template for iOS. So, I want to develop an cross-plattform game for iOS, Mac & Windows. GLKit seems like a step backwards in terms of portability, but the GLKit Features (specially like asynchronous texture loading) are great benefits...

How can I develop a cross-plattform game with GLKit? I would need to write any grapics code twice, right? Or is there something like an GLKit implementation for windows?

Any idea, workaround, code-design advice (how to divide the GLKit Code from other components?) is welcome - thanks!

like image 302
Constantin Avatar asked Feb 02 '12 18:02

Constantin


1 Answers

I can't think of anything that GLKit does which cannot be replaced by non-GLKit code. It can make some OpenGL ES 2.0 tasks simpler by abstracting them away from you, but it doesn't do anything unique. The closest it comes to having something you can't replicate elsewhere (from what I've tinkered with) is the accelerated matrix and vector math functions it provides, but even those could be replaced with a little Accelerate or NEON code.

While I'd like to use GLKit within my applications, I'm still supporting iOS 4.2 with them, which doesn't have GLKit available. There's nothing that I'm currently prevented from doing because I can't use GLKit, I just have to write a little more code to handle things like view updates, texture uploads, matrix math, etc. There's plenty of documentation and examples out there for these operations, so you don't need to worry about being on your own when it comes to implementing them.

You're going to have much larger problems than GLKit when trying to make your code be cross-platform with the Mac, and expecially so with Windows. Desktop OpenGL and OpenGL ES have some differences in their implementations, and you'll need to be aware of the places to substitute one function or built-in variable for another. CAOpenGLLayer and NSOpenGLView on the Mac are also different from the CAEAGLLayer on iOS, and AppKit overall is a different animal than UIKit.

Windows will be even more of a challenge to support, because you won't be able to use any of the Cocoa frameworks, and most likely no Objective-C as well. This will take a lot more of your time than any OpenGL / OpenGL ES differences.

like image 58
Brad Larson Avatar answered Oct 01 '22 17:10

Brad Larson