Wiki

Clone wiki

Core / GLSLES

OpenGL ES Shading Language references and guides

Vertex and fragment shaders in Codea version 1.5 use the OpenGL ES Shading Language (also known as GLSL ES or ESSL), which is based on the OpenGL Shading Language (GLSL) version 1.20. The following sites have information you may find useful about GLSL ES language and programming in it:

Apple provides different implementations of OpenGL ES for different hardware platforms. Information about the limits for the graphics platform of the iPad are available in the Platform Notes in the OpenGL ES Programming Guide for iOS.

Frequently asked questions

The following GLSL ES-specific matters frequently give rise to questions or requests for help on the Codea Forum.

Integer constants and floating-point constants

Lua has a single number type, but GLSL ES has two distinct types for numbers: int (for integer variables) and float (for floating-point variables) (see Section 4.1.3 'Integers' and Section 4.1.4 'Floats' of the GLSL ES specification).

Floating-point constants must have a decimal point. For example

float a = 0.0 // Correct
float b = 0.  // Correct
float c = .0  // Correct
float d = 0   // Error: 0 is not a floating-point constant and is incompatible with variable d

Statements ending with semi-colons

The use of semi-colons (;) to separate statements is optional in Lua. In GLSL ES, declaration statements, expression statements and jump statements must end in a semi-colon (see Section 6 'Statements and Structure' of the GLSL ES specification).

Limits in the implementation of OpenGL ES 2.0 on the iPad

The following are limits in the implementation of OpenGL ES 2.0 on the iPad (as of iOS 4.2).

AspectMaximum
2D texture size2048 x 2048
Cube map texture size2048 x 2048
Textures in a vertex shader0 (none)
Textures in a fragment shader8
Vertex attributes16
Varying vectors8
Uniform vectors in a vertex shader128
Uniform vectors in a fragment shader64
Size of points511.0 pixels
Width of lines16.0 pixels

Updated