Until now Codea’s shaders have used GLES 2.0
Starting with 2.3.2 beta build 56, optional support for GLES 3.0 is added.
This is only available on devices with an A7 chip or newer (iPad Air onwards).
(and is currently only available to Codea beta testers).
GLES 3.0 is optional, and can be added on a shader-by-shader basis (ie you can mix 2.0 and 3.0 in the same program) by placing #version 300 es
in the string of the vertex and fragment shaders, so you should be able to add it gradually, if it’s needed for your code.
This Apple page is quite a handy cheat sheet to the changes you need to make to the shader language : https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/AdoptingOpenGLES3/AdoptingOpenGLES3.html#//apple_ref/doc/uid/TP40008793-CH504-SW18
And regardless of which GLES version you use, you can never read this page enough times:
The most useful resource is probably the quick reference card (pages 4 to 6 is the relevant section):
https://www.khronos.org/files/opengles3-quick-reference-card.pdf
And this is the bible:
https://www.khronos.org/registry/gles/specs/3.0/GLSL_ES_Specification_3.00.4.pdf
Here’s some very simple sample code:
-- test of GLES 300 Matrix Mesh Buffer Test
--
function setup()
m = mesh()
m:addRect(0,0,200,200)
m:setColors(color(255,200,0))
m.shader = shader(vert, frag)
dummy = m:buffer("dummy") --test vec4 attribute
transform = m:buffer("transform") --test mat4 attribute
local mat = matrix():translate(0,100,0) --should move rectangle up
for i=1,m.size do
dummy[i] = vec4(60,0,0,0) --works, moves rectangle to right
transform[i] = mat
end
end
function draw()
background(40, 40, 50)
perspective()
camera(0,0,400, 0,0,0)
m:draw()
end
vert=[[
#version 300 es
uniform mat4 modelViewProjection;
in mat4 transform;
in vec4 position;
in vec4 color;
in vec4 dummy;
out lowp vec4 vColor;
void main()
{
vColor = color;
gl_Position = modelViewProjection * (transform * position + dummy);
}
]]
frag=[[
#version 300 es
in lowp vec4 vColor; //NB varying becomes "in" in fragment shader
out lowp vec4 fragColor;
void main()
{
fragColor = vColor;
}
]]