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:
glCompileShader(shader.id);
GLint result;
glGetShaderiv(shader.id, GL_COMPILE_STATUS, &result);
if(result == GL_FALSE)
{
std::cout << "Could not compile shader: " << shader.id << ": " << shader.filename << std::endl;
outputShaderLog(shader.id);
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