For a long time I focused in using OpenGL ES 2.0 in my game engine. I was aware that iOS devices now supported OpenGL ES 3.0. But I was afraid of porting over to this version. Part of that fear was not knowing answers to questions such as: How much did the OpenGL API changed? Will I have to change all my Shaders? How much will I have to change in the engine?
It turns out that porting an application to OpenGL ES 3.0 is not that complicated. The concepts to keep in mind are:
1. You no longer use the keyword attribute in vertex shaders
Instead, you now use the keywords in and out. The keyword in replaces the keyword attribute in vertex shaders. The keyword out replaces the keyword varying in shaders.
For example:
Vertex Shader
#version 300 es
in vec4 position;
out lowp vec4 newColor;
2. You no longer need to find the location of a vertex attribute
Remember how you needed to find the location of a vertex attribute by calling glGetAttribLocation()? That is no longer necessary. You can set the location of the vertex attribute by using the following:
Vertex Shader
#version 300 es
layout(location=1) in vec4 position;
layout(location=2) in vec3 normal;
3. You no longer need to use gl_FragColor in fragment shaders
You can now set your own out variable that will sent data to the framebuffer. For example:
Fragment Shader
#version 300 es
in lowp vec4 newColor;
//variable that will sent data to framebuffer
layout(location=0) out lowp vec4 color;
void main()
{
color = newColor;
}
I hope this helps in case you plan to port your OpenGL ES 2.0 project to use OpenGL ES 3.0
PS. Sign up to my newsletter and get OpenGL development tips.