I am trying to implement instancing in my android-game - that is to draw 64 sprites in one draw-call.
I am following a tutorial based on the c-language
https://learnopengl.com/#!Advanced-OpenGL/Instancing
the program crashes when I use the following syntax in the vertex-shader-code
vec2 offset = offsets[gl_InstanceID];
exception
09-19 17:28:18.315 3635-3674/? E/ShaderHelper: Error compiling shader: 0:47: L0002: Undeclared variable 'gl_InstanceID'
So why can I not access the instanceID variable? I've already set the GLcontextClientVersion to 3 in the customized GLSurfaceview.
gl_InstanceID is a ES 3.0 feature. From the GLSL ES 3.00 spec chapter 3.4 we read:
The directive “#version 300 es” is required in any shader that uses version 3.00 of the language. Any number representing a version of the language a compiler does not support will cause an error to be generated. Version 1.00 of the language does not require shaders to include this directive, and shaders that do not include a #version directive will be treated as targeting version 1.00.
My humble guess is you missed typing "#version 300 es" as first line in the shader so the compiler assumes version 1.00.