I am trying to generate OpenGL primitives out of a 6 integer Vertex.
I.E. the 6 integer value will generate 4 custom line_strip
.
First I am trying to move the 6 integer array from Vertex to Shader and in order to do that I am doing a simple test as follows.
This is the code for the Vertex Shader:
#version 330
layout (location = 0) in int inVertex[6];
out int outVertex[6];
void main()
{
outVertex = inVertex;
}
And for the Geometry Shader, which hardcodes a segment:
#version 330
in int vertex[6];
layout (line_strip, max_vertices = 2) out;
void main()
{
gl_Position = vec4(-0.2, -0.2, 0.0, 1.0);
EmitVertex();
gl_Position = vec4(-0.2 +0.4, -0.2, 0.0, 1.0);
EmitVertex();
EndPrimitive();
}
But I get an empty screen.
If I modify the Vertex shader to this:
#version 330
layout (location = 0) in int inVertex[6];
out int outVertex[6];
void main()
{
//outVertex = inVertex;
gl_Position = vec4(0.0, 0.0, 0.0, 0.0);
}
and the Geometry Shader to this:
#version 330
//in int candle[6];
layout (points) in;
layout (line_strip, max_vertices = 2) out;
void main()
{
gl_Position = vec4(-0.2, -0.2, 0.0, 1.0);
EmitVertex();
gl_Position = vec4(-0.2 +0.4, -0.2, 0.0, 1.0);
EmitVertex();
EndPrimitive();
}
Then I get the segment in the screen:
Is it mandatory to use gl_Position? If so, How can I pass additional variables together to gl_Position to enrich my Vertex?