<!--
{
  "documentType" : "article",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/executing-shaders-in-metal-and-opengl",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Executing Shaders in Metal and OpenGL"
}
-->

# Executing Shaders in Metal and OpenGL

Toggle between renderers to make sure your shader code compiles in both the Metal and OpenGL environments.

## Discussion

On devices that support it, the GLSL code you provide to [`SKShader`](/documentation/SpriteKit/SKShader) is automatically converted to Metal shading language and run on a Metal renderer. On older devices, shader code is run in OpenGL. It’s important to be mindful of this for debugging purposes because some issues may appear in one renderer but not the other.

You can specify which renderer your device uses—for example, forcing a Metal-enabled device to use SpriteKit’s OpenGL renderer for debugging purposes—by adding a `PrefersOpenGL` to your app’s `Info.plist` key with a value of `true`. See [Requesting the OpenGL Renderer](/documentation/SpriteKit/requesting-the-opengl-renderer) for more information.

> Important:
> To ensure compatibility across all devices, test your shader code with and without the `PrefersOpenGL` key, to be certain it compiles in both environments.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)