0
\$\begingroup\$

Got a real annoying problem here.

My shader program compiles fine on my Ati Radeon HD card, but on Nvidia and Intel it failes to compile.

Vertex shader:

#version 120
attribute vec3 in_position;
 attribute vec3 in_normal;
 attribute vec3 in_texcoord;

 uniform mat4 modelMatrix;
uniform mat4 viewMatrix;
uniform mat4 projMatrix;

varying vec2 texture_coordinate;
varying vec3 normal;

void main()
{
gl_Position = (projMatrix * viewMatrix * modelMatrix) * vec4(in_position, 1.0);
normal = in_normal;
texture_coordinate = in_texcoord.xy;
}

Fragment shader:

#version 120
varying vec2 texture_coordinate;
varying vec3 normal;

uniform sampler2D gColorMap;

 void main()
 {
   gl_FragData[0] = vec4(texture(gColorMap, texture_coordinate).xyz, 1.0f);
   gl_FragData[1] = vec4(normalize(normal), 1.0f);
}

Any ideas? I checked the shader for errors, but I can't find anything. Thanks.

\$\endgroup\$
  • \$\begingroup\$ I haven't worked with OpenGL for some longer time. But I think attributes are available from version 130, aren't they? \$\endgroup\$ – kravemir Jun 10 '13 at 12:05
  • \$\begingroup\$ Yup, that's it. Changed it to 130 and it now works fine :) Please add an answer so I can mark it. \$\endgroup\$ – Basaa Jun 10 '13 at 13:25
  • 3
    \$\begingroup\$ What errors were you getting? \$\endgroup\$ – Nicol Bolas Jun 10 '13 at 17:36
8
\$\begingroup\$

The GLSL function texture and the output gl_FragData are only available in GLSL version 1.30 or better.

So, change line #version 120 to #version 130

To find compile problems you should use glGetShaderInfoLog and glGetProgramInfoLog

\$\endgroup\$
  • \$\begingroup\$ You're welcome. I'm glad I helped you :) \$\endgroup\$ – kravemir Jun 10 '13 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.