What is what (GL, GL ES, GLSL)?

Whenever libGDX is talking about GL20 or GL30, it is in fact referring to GL ES 2.0 and GL ES 3.0. OpenGL ES can be seen as a subset of OpenGL and is designed for embedded systems (smartphones in particular).

By default, version 2.0 of OpenGL ES is used, but libGDX can be configured to use 3.0 as well. See for example:

  1. LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration();
  2. // ...
  3. cfg.useGL30 = true;

And what about GLSL (ES)?

GLSL (or GLSL ES for mobile and web) is the language used for shaders. Its versioning is somewhat confusing:

GLSL - click to expand

Open GL VersionGLSL Version
2.0110
2.1120
3.0130
3.1140
3.2150
3.3330
4.0400
4.1410
4.2420
4.3430
4.4440
4.5450
4.6460

For some advice on porting shaders from version 120 to 330+, see here.

GLSL ES - click to expand

OpenGL ES VersionGLSL EL VersionBased on GLSL Version (OpenGL)
2.0100120 (2.1)
3.0300 es330 (3.3)

Platform specificities

Desktop (Windows, Mac, Linux)

On Desktop, libGDX is mapping all its graphics calls to OpenGL.

GL ES 2.0 is roughly based on Open GL 2.0, however, there are some incompatibilities that weren’t resolved until Open GL 4.1. To mimic GL ES 2.0, libGDX does not request any specific OpenGL version, so the driver will be more forgiving.

GL ES 3.0 is the successor of OpenGL ES 2.0. On desktop, OpenGL 4.3 provides full compatibility with OpenGL ES 3.0. For mimicking GL ES 3.0 on desktop, one can specify the exact OpenGL version, that should be used. Please note that MacOS only supports the OpenGL 3.2 core profile.

Android

On Android Open GL ES 2.0 and 3.0 can be used. To prevent your application from being shown to unsupported devices in the Play Store, add one of the following lines to your Android Manifest:

  • OpenGL ES 2: <uses-feature android:glEsVersion="0x00020000" android:required="true" />
  • OpenGL ES 3: <uses-feature android:glEsVersion="0x00030000" android:required="true" />

iOS

Please note that support for OpenGL ES 3.0 is experimental on iOS.

Web

On Web, the graphic stuff is handled by WebGL. Web only supports GL ES 2.0.

Precision modifiers

OpenGL ES 2.0 requires the specification of precision modifiers for attributes, uniforms and locals. Desktop OpenGL does not support this. You will have to guard against that in your fragment shader with something similar to this code snippet:

  1. #ifdef GL_ES
  2. #define LOW lowp
  3. #define MED mediump
  4. #define HIGH highp
  5. precision mediump float;
  6. #else
  7. #define MED
  8. #define LOW
  9. #define HIGH
  10. #endif

This will define the LOWP, MED, and HIGH macros to equivalent OpenGL ES precision modifiers and sets the default precision for float to medium. This will only happen on platforms actually running OpenGL ES, on the desktop, the macros are defined to be empty.

OpenGL ES 2.0 Documentation