GLSL compile error

Hi everyone.
It’s my first approach to GLSL. I’m trying to run a simple program but I found some problems and I don’t know how to fix them.

The program doesn’t compile my shaders, the code is simple:

.vertex shader:

#version 120

uniform mat4 projection_matrix;
uniform mat4 modelview_matrix;

in vec3 a_Vertex;
in vec3 a_Color;
out vec4 color;

void main(void)
	vec4 pos = modelview_matrix * vec4(a_Vertex, 1.0);
	gl_Position = projection_matrix * pos;
	color = vec4(a_Color, 1.0);

fragment shader:

#version 120

in vec4 color;
out vec4 outColor;

void main(void) 
	outColor = color;

Here is the code that compiles shaders:

		GLint result;
		glGetShaderiv(, GL_COMPILE_STATUS, &result);
		if(result == GL_FALSE)
			std::cout << "Could not compile shader: " << << ": " << shader.filename << std::endl;
            return false;
		return true;

The error log is the same for both shaders:

ERROR: 0:6: ‘in’ : syntax error syntax error
ERROR: Parser found no code to compile in source strings

I’ don’t know how to fix these errors.
I’m using Xcode for Snow Leopard.
Thank you

Just change the first line from #version 120 to #version 150.
in and out are not defined in GLSL version 120

The problem is that you are using GLSL under Snow Leopard, which does not support GLSL > 120, so you need to use legacy GLSL code.

You need to change in to attribut and out to varying. Check for other version inconsistencies.

Thank you very much!

I’ve changed in to attribute and out to varying, and used gl_FragColor in fragment shader (instead of out variables), but I don’t change version 120 to 150 (I suppose it’s not a problem).
Now the program works!
thank you

In fact, if you had change to version 150 it will recognize in and out keywords. The problem is that this version is not supported by snow leopard.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.