1

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...^^

2
  • You claim the vertex shader compiled fine yet you've posted Shader compile error: Vertex shader compilation failed. Commented Jul 9, 2013 at 14:38
  • idk it is what opengl said, but i compile vertex shader and then fragment shader and at fragment shader this error occurs Commented Jul 9, 2013 at 15:19

1 Answer 1

4

GLSL, like C, is case sensitive.

Try gl_FragColor. Note the CamelCase.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.