1

Topic is pretty much the question. I have OpenGL-based game with a lot of shaders. What I wanna do is convert it to Metal, so it can gain some perfomance from conversion, but I also want to have old devices support. Is it possible?

Andrew Volodin
  • 159
  • 1
  • 10

3 Answers3

0

I dont know for sure if that works but You could check which iOS device is used Detect the specific iPhone/iPod touch model

And than execute the metal Code or the OpenGL es Code

Community
  • 1
  • 1
Maximilian
  • 754
  • 1
  • 5
  • 26
0

Have a look at MetalGL. It is an implementation of OpenGL ES that runs on Metal. You write your app in OpenGL ES, and if Metal is available on the device, MetalGL will run the OpenGL ES code on Metal automatically, including shader conversion. If Metal is not available on the device, MetalGL will run the native OpenGL ES engine.

Depending on the nature of your app bottlenecks, your app may be more performant when running on Metal, and MetalGL can help you understand if and how your app will benefit from Metal, without you having to rewrite your app in Metal.

Full disclosure...I work on the MetalGL development team.

Bill Hollings
  • 2,344
  • 17
  • 25
  • Hi, Bill! I know you from cocos2d forums. What if I use cocos2d-objc 3.4.9, can it be applied to my app? – Andrew Volodin Sep 27 '15 at 19:26
  • Hi Andrew. Actually, I believe that version of Cocos2D already supports Metal directly. But if not, MetalGL has been tested against Cocos2D 3.2 at least, so it shouldn't have any trouble. – Bill Hollings Sep 27 '15 at 19:32
0

Yes it is possible. I do it in a released game. To test for Metal support on a device call:

// this returns NULL if the device does not support Metal
Class metalAvailable = NSClassFromString(@"CAMetalLayer");

Then take separate paths in your code to either initialise your Metal renderer or your OpenGL ES renderer. It's all pretty easy.

Muzza
  • 1,236
  • 9
  • 13