When using layout(points) in
in geometry shader, I can simply forward the data through the vertex shader by suppling gl_Position with a vec4
:
// Vertex Shader
in vec2 position;
void main()
{
gl_Position = vec4(position, 0.0, 1.0);
}
// cpp file
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW);
GLint posAttrib = glGetAttribLocation(shaderProgram, "position");
glEnableVertexAttribArray(posAttrib);
glVertexAttribPointer(posAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0);
And then I can access it with gl_in[0].gl_Position
in geometry shader.
But what if I wanted to instead take input into the geometry shader using layout(lines) in
? Could this be done by forwarding values through vertex shader or is there another way?
In short: How would one provide line data to the geometry shader so that it can be accessed using gl_in[0].gl_Position
and gl_in[1].gl_Position
?