Hi all,
I’m trying to use a Geometry shader.
My OpenGL program is compossed by this 3 shaders:
//#shader vertex
#version 330 core
layout(location=0) in vec4 position;
layout(location=1) in float type;
uniform vec4 u_colors[4];
out vec4 fragmentColor;
uniform mat4 u_view;
uniform mat4 u_model;
uniform mat4 u_proj;
void main() {
gl_Position = u_proj * u_view * u_model * position;
fragmentColor = u_colors[int(type)];
}
//#shader fragment
#version 330 core
in vec4 fragmentColor;
out vec4 color;
void main() {
color = fragmentColor;
}
//#shader geometry
#version 330
layout (lines) in;
layout (line_strip, max_vertices = 2) out;
in vec4 vFragColorVs[2];
out vec4 vFragColor;
void main(void) {
int i;
for ( i=0; i < gl_in.length(); i++) {
vFragColor = vFragColorVs[i];
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
When I try to compile it there are no compilation errors.
Thats the code that I use to link:
glLinkProgram(rendererID);
GLint isLinked = 0;
glGetProgramiv(rendererID, GL_LINK_STATUS, &isLinked);
if (isLinked == GL_FALSE)
{
int length;
std::string log;
glGetProgramiv(rendererID, GL_INFO_LOG_LENGTH, &length);
log.reserve(static_cast<unsigned long>(length));
glGetProgramInfoLog(rendererID, length, &length, &log[0]);
// The program is useless now. So delete it.
glDeleteProgram(rendererID);
std::cerr << "cannot Link: " << log << std::endl;
throw std::runtime_error("cannot link opengl program");
}
The output is only cannot link: without a log message.
The program without the Geometry shader links and works well.
Where is the mistake?