1
votes

i get a shader compile error in my android project and i have no idea whats wrong with it:

Shader compile error: Vertex shader compilation failed.
ERROR: 0:4: 'gl_FragColor' : undeclared identifier
ERROR: 0:4: 'assign' :  cannot convert from 'varying 4-component vector of float' to 'float'
ERROR: 2 compilation errors.  No code generated.

VertexShader:

uniform mat4 u_MVPMatrix;
attribute vec4 a_Position;
attribute vec4 a_Color;
varying vec4 v_Color;
void main() {
    v_Color = a_Color;
    gl_Position = u_MVPMatrix * a_Position;
}

Fragment Shader:

precision mediump float;
varying vec4 v_Color;
void main() {                         
  gl_fragcolor = v_Color;
} 

The vertex shader compiles perfect, but the fragment shader doesn't work. Since the code is from a tutorial it should work and when i launch the tutorial project there is no compilation error. I don't understand it because i copied the shader code 1:1 multiple times now and it still won't work.

Solved: I found the problem... I was compiling the shader via a method but the method always used glCreateShader(GL_VERTEX_SHADER); no wonder it couldn't compile the fragment shader. Also this is the reason why on the log it says 'Vertex shader compilation failed', such a dump mistake costs tons of hours...^^

1
You claim the vertex shader compiled fine yet you've posted Shader compile error: Vertex shader compilation failed.genpfault
idk it is what opengl said, but i compile vertex shader and then fragment shader and at fragment shader this error occurshawelo

1 Answers

4
votes

GLSL, like C, is case sensitive.

Try gl_FragColor. Note the CamelCase.