Skip to content

Instantly share code, notes, and snippets.

@mokiat mokiat/opengl.md
Last active Oct 9, 2016

Embed
What would you like to do?
OpenGL

OpenGL

The idea of this Gist is to track common pitfalls when using OpenGL.

Shaders

  • Multiple shaders of the same type cannot be attached to a single shader program. (e.g. there can only be one vertex program and one fragment program attached to the shader program)

Not specifying minimum precision of your shader variables.

Simptom: Your app crashes on certain devices.

Reason: Some devices require that you specify a minimum precision for the variables.

Solution: Either specify minimum precision per variable with the lowp, mediump, highp flags or use the following global configurations in your vertex and fragment shaders.

precision lowp float;
precision lowp sampler2D;
// ...

Textures

Using non power-of-two sized images

Simptom: You texture is not rendered and instead the polygon is rendered black.

Reason: You are using a texture that is not 2^n in width or height and the device does not support it.

Solution: Have your textures 2^n x 2^m in dimension. Scale (preferably up) your images if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.