Search code examples
macosopenglscenekitmetal

Force SCNView to use OpenGL


When using Xcode 7 and creating a new SceneKit OS X project, it seems to default to using Metal for the SCNView.

If I try to do this after creating a new Game project in Xcode 7:

var context = gameView.context

The result is nil. The view is using Metal and not OpenGL.

However, creating the same in Xcode 6.4, the context exists like expected.

How can I force my SCNView to use OpenGL and not Metal?


Solution

  • When creating an SCNView, you have an option to set the renderer in the initialiser:

    https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNView_Class/index.html#//apple_ref/occ/instm/SCNView/initWithFrame:options:

    These are the options you have available, Metal or OpenGL ES 2.0 (3.0 will likely come later):

    https://developer.apple.com/library/prerelease/ios/documentation/SceneKit/Reference/SCNSceneRenderer_Protocol/index.html#//apple_ref/c/tdef/SCNRenderingAPI

    So setting to SCNRenderingAPIOpenGLES2 will get you what you want, a forcibly OpenGL ES 2.0 rendered SceneKit View