EmitVertex 给出 "error C1067: too little data in type constructor"

EmitVertex gives "error C1067: too little data in type constructor"

我正在使用几何着色器从 GL_POINTS

生成立方体
#version 150 core

layout(points) in;
layout(triangle_strip, max_vertices = 18) out;

in vec3 g_col[];

out vec3 f_col;

uniform mat4 transform;

void main()
{
    f_col = g_col[0];

    float s = gl_in[0].gl_PointSize * 0.5;

    vec4 c = gl_in[0].gl_Position;

    // Bottom

    gl_Position = transform * (c + vec4 (-s, -s, -s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (+s, -s, -s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (-s, +s, -s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (+s, +s, -s, 0));
    EmitVertex();

    // Far

    gl_Position = transform * (c + vec4 (-s, +s, +s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (+s, +s, +s, 0));
    EmitVertex();

    // Top

    gl_Position = transform * (c + vec4 (-s, -s, +s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (+s, -s, +s, 0));
    EmitVertex();

    // Near

    gl_Position = transform * (c + vec4 (-s, -s, -s, 0));
    EmitVertex();

    gl_Position = transform * (c + vec4 (+s, -s, -s, 0));
    EmitVertex();

    EndPrimitive();

    // Left

    gl_Position = transform * (c + vec4 (-s, -s, -s));
    EmitVertex ();

    gl_Position = transform * (c + vec4 (-s, +s, -s));
    EmitVertex ();

    gl_Position = transform * (c + vec4 (-s, -s, +s));
    EmitVertex ();

    gl_Position = transform * (c + vec4 (-s, +s, +s));
    EmitVertex ();

    EndPrimitive ();
}

如果我删除第一个 EndPrimitive 之后的代码(在 // Left 评论之前),这会正确地在立方体周围绘制一条条带,使边没有封顶。

如果我尝试绘制一个新的三角形带来盖住边,我在随后的四个 EmitVertex 调用中的每一个都会收到此错误:

error C1067: too little data in type constructor

根据this documentation

The GS defines what kind of primitive these vertex outputs represent. The GS can also end a primitive and start a new one, by calling the EndPrimitive() function. This does not emit a vertex.

In order to write two independent triangles from a GS, you must write three separate vertices with EmitVertex() for the first three vertices, then call EndPrimitive() to end the strip and start a new one. Then you write three more vertices with EmitVertex().

我做错了什么?

在工作部分:

gl_Position = transform * (c + vec4 (+s, -s, -s, 0));

在非工作部分:

gl_Position = transform * (c + vec4 (-s, -s, -s));

一个 vec4 构造函数需要四个组件,正如错误消息告诉您的那样。