无法正确链接几何着色器

Asonic84

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

顶点着色器代码:

#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();
}

调试输出:

在 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 版本号:4.6 GLSL 版本:4.60 NVIDIA --------------- 调试消息(131216):程序/着色器状态信息:GLSL 程序 1 无法链接源:API 类型:其他严重性:低

曲线着色器程序未链接 曲线着色器程序未验证 使用不成功,返回?m_linked 状态:false 程序句柄:1 曲线着色器程序句柄:1

疯兔76

几何着色器变换的原语和用于每个原语被执行。因此,几何着色器的输入是一个大小为图元顶点数的数组。例如:

in vec4 color[];

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章