Geometry shader can't do basic triangle lists? - only strips?

I was under the impression that the geometry shader - even though it’s only has triangle-strips - could still output triangle lists?

Maybe I’m wrong? If someone could let me know?

For example, my simple test case, I have three triangles:

Positions.push_back( Vector3f(  0.000000, 1.000000, 0.000000));
Positions.push_back( Vector3f(  -1.000000, -1.000000, 0.000000));
Positions.push_back( Vector3f(   1.000000, -1.000000, 0.000000));

Positions.push_back( Vector3f(  -1.000000, -2.000000, 0.000000));
Positions.push_back( Vector3f(   1.000000, -2.000000, 0.000000));

Indices.push_back( 0 );  
Indices.push_back( 1 );   
Indices.push_back( 2 );

Indices.push_back( 1 );  
Indices.push_back( 3 );   
Indices.push_back( 4 );

Indices.push_back( 1 );  
Indices.push_back( 4 );   
Indices.push_back( 2 );

// Very basic drawing code
glDisable( GL_CULL_FACE );

glBindBuffer(GL_ARRAY_BUFFER, m_particleBuffer[m_currTFB]);    
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0); // position
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_indexBuffer);

glDrawTransformFeedback(GL_TRIANGLES, m_transformFeedback[m_currTFB]);



// Basic geometry shader

layout(triangles) in;
layout(triangle_strip) out; //
layout (max_vertices = 3) out;

void main()
for(int i=0; i<3; i++)
Position1 = Position0[i];

// Basically, I have two triangle mesh lists - and I’m toggling back and forth to update the
// mesh data using the geometry shader - but want the data
// to remain as triangle-lists? However, it seems to fail - for example, the simple three triangles
// I only have the first triangle and the second two aren’t updated?

Thank you for any advice/help


I’m confused by your description of your problem.

Your GS will output 3 vertices for each primitive it receives. That makes for a single triangle. Therefore, your rendering operation will output a sequence of triangles. AKA: a list.

The confusing bit is your “Very basic drawing code” (FYI: transform feedback is not “very basic”). It looks like this code is trying to render the output of a previous feedback operation. But you don’t actually show us when you issue that operation.

It seems like you’re saying that you are ping-ponging back and forth, rendering from one buffer into another, and then vice-versa. I’m not exactly sure why you’re doing that or what you intend to accomplish with it. More importantly, because you didn’t show us the initial rendering call, I can’t say for certain if ping-ponging will work with that.

For example, you show us that you have built a vertex array and an index list. But you don’t show us you rendering with it. And that’s kinda the problem. Because, while you can render with an index list, you cannot render the result of a transform feedback operation with one. I don’t know if you’re trying to do that or not.

Also, please use proper formatting. Especially for your source code.

Hey Alfonse,
thank you for your reply - I was trying to ping-pong the original tri-mesh data back and forth using the geometry shader (adapting the original vertex data), while keeping the indexes the same, so I could pass it to another shader. Which seems fine for points - but doesn’t seem happy with any tri-list models. Hence, I’ve given up on it and am using CUDA/OpenCL.

Thank you for your help, Ben