We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am working on GLES program using ARM GLES3.1 Emulator ver 2.2.
glShaderSource is giving 'GL_INVALID_OPERATION' error if shader is of following form
============================================
#ifndef GL_ES
#version 400 core
#define mediump
in vec3 position;
void main() {
gl_Position = vec4(position, 1.0);
}
#else
attribute vec3 position;
#endif
=======================================================
On console it writes FATAL - GLES: <gles::GLES31Api::glShaderSource 126> Invalid version detected.
It seems it is due to line "#version 400 core", but I wonder why it should go to this line when GL_ES is defined.
Hi Sunil,
I think you shader is not "exactly" conformant to OpenGL ES Language specification.
According to Chapter 3.3. Version Declaration from The OpenGL ES Shading Language specification:
"The #version directive must be present in the first line of a shader and must be followed by a newline. It
may contain optional white-space as specified below but no other characters are allowed. The directive is
only permitted in the first line of a shader."
If you are targeting OpenGL ES, that would mean should not start a shader with #ifndef GL_ES statement if you plan to use #version directive in it.
We know that some shader language compilers have less strict rules and not really follow official specification. This is where our OpenGL ES Emulator differs a bit.
We've captured your issue and we will consider whether we should relax our shader compilation validation in the Emulator for one of next possible releases. At this point GL_INVALID_OPERATION is the correct and conformant result.
Thanks Adam. Really appreciate.