无法正确 link 几何着色器

unable to link geometry shader properly

我正在尝试创建一个简单的直通“几何着色器”,但由于某种原因它没有链接。调试信息说它正在编译 fine.I 不知道我在这方面做错了什么?它不是驱动程序或 OS,因为我之前链接并使用过几何着色器,它们工作正常。

顶点着色器代码:

#version 450

in vec3 position;
uniform mat4 MVP;
out vec4 color;

void main()
{
    gl_Position = MVP * vec4(position, 1.0);
    color = vec4(0.5, 0.5, 0.0, 1.0);
}

片段着色器代码:

#version 450

in vec4 fColor;
out vec4 fcolor;

void main() {
    fcolor = fColor;
}

几何着色器代码:

#version 450

layout(lines) in;
layout(triangle_strip, max_vertices = 4) out;

in vec4 color;
out vec4 fColor;

void main()
{
    fColor = color;
    for(int i = 0; i <= gl_in.length(); i++)
    {
        gl_Position = gl_in[i].gl_Position;
        EmitVertex();
    }
    EndPrimitive();
}

调试输出:

In Compile Shader from file: ../Curve.vert compile result:: 1 Shader compile and attach success: In Compile Shader from file: ../Curve.geom compile result:: 1 Shader compile and attach success: In Compile Shader from file: ../Curve.frag compile result:: 1 Shader compile and attach success: Linking.. , Program handle found: 1 GL Renderer : GeForce GTX 1660 Ti/PCIe/SSE2 GL Vendor : NVIDIA Corporation GL Version : 4.6.0 NVIDIA 461.40 GL Version No. : 4.6 GLSL Version : 4.60 NVIDIA --------------- Debug message (131216): Program/shader state info: GLSL program 1 failed to link Source: API Type: Other Severity: low

Curve shader program not linked Curve shader program not validated Use unsuccessful, returning? m_linked status: false Program handle: 1 Curve shader program handle: 1

Geometry Shader transforms Primitives 并为每个图元执行。因此,几何着色器的输入是一个数组,大小为图元的顶点数。例如:

in vec4 color[];

您必须为输出图元的每个顶点发射一个顶点。