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:
- GLSL ES Specification version 1.0.17
- OpenGL ES Shading Language 1.0 Quick Reference Card (on pages 3 and 4)
- The GLSL Sandbox gallery at glsl.heroku.com: To get the most from this site you need a browser that supports WebGL. At the time of writing, no iOS browsers support WebGL.
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).
|2D texture size||2048 x 2048|
|Cube map texture size||2048 x 2048|
|Textures in a vertex shader||0 (none)|
|Textures in a fragment shader||8|
|Uniform vectors in a vertex shader||128|
|Uniform vectors in a fragment shader||64|
|Size of points||511.0 pixels|
|Width of lines||16.0 pixels|