I am experimenting with OpenGL ES 3.0 and found the following statement in a quick reference:
"# version 300 es" should appear on the first line of the shader program written in GLSL ES version 3.00. If omitted, the shader will be considered as targeting version 1.00.
Therefore, I tried to add this at the beginning of my shaders, but this only led to an error
Communication error due to invalid vertex shader.
as reported .glGetProgramInfoLog . If I delete the first line using the "#version 300 gl" operator, the shader compiles and works.
This is the code for my vertex shader.
private final String vertexShaderCode = "#version 300 es \n" + "uniform mat4 uMVPMatrix; \n" + "attribute vec2 a_TexCoordinate; \n" + "attribute vec4 vPosition; \n" + "varying vec2 v_TexCoordinate; \n" + "void main() { \n" + " v_TexCoordinate = a_TexCoordinate; \n" + " gl_Position = uMVPMatrix * vPosition; \n" + "} \n";
I also added a version statement to the vertex and fragment shader and still get the same error.
I call setEGLContextClientVersion(3) in my GLSurfaceView, and I added <uses-feature android:glEsVersion="0x00030000" android:required="true" /> in my manifest to indicate that the application requires OpenGL ES 3.0.
Am I reading OpenGL ES documentation incorrectly and don’t need to add this version statement? If I need to add it, what am I doing wrong, does this always lead to an error?
source share