So I seem to have some trouble getting a geometry shader working with "glDrawArrays(GL_LINE_STRIP, 0, 4);". When I omit the geometry shader and make some minor variable changes, the vertex and fragment shader outputs the line strips properly, but adding the geometry shader somehow doesn't output anything (there doesn't seem to be any compile issues).
I have also tried modifying the geometry shader to be a passthrough shader, and even that fails to output anything.
Code attached below. Intention of the pipeline is to interpolate 4 colors across corners of a quad given as 4 vertices, so geometry shader is for coalescing data. Note that "pos" in "GS_OUT" in the fragment shader is unused right now because code has been heavily modified after testing.
Vertex Shader:
#version 460 core
in vec2 in_Position;
in vec3 in_Color;
out VS_OUT
{
vec2 position;
vec3 color;
} vs_out;
void main(void)
{
vs_out.position = in_Position;
vs_out.color = in_Color;
gl_Position = vec4(in_Position, 0.0, 1.0);
}
Geometry Shader:
#version 460 core
layout (lines_adjacency) in;
layout (triangle_strip, max_vertices = 4) out;
in VS_OUT
{
vec2 position;
vec3 color;
} gs_in[4];
// tl, tr, bl, br
out GS_OUT
{
flat vec2 pos[4];
flat vec3 rgb[4];
} gs_out;
void main() {
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
gs_out.pos[j] = gs_in[j].position;
gs_out.rgb[j] = gs_in[j].color;
}
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}
Fragment Shader:
#version 460 core
precision highp float;
// tl, tr, bl, br
in GS_OUT
{
flat vec2 pos[4];
flat vec3 rgb[4];
} fs_in;
out vec4 fragColor;
void main(void)
{
fragColor = vec4(fs_in.rgb[0], 1.0);
}