Geometry Shader: Meaning of gl_VerticesIn?

I am trying to write a geometry shader that will take as input the four vertices that define a tetrahedron (input as GL_ POINTS), and use the group of four points to draw the four faces of the tetrahedron. So I have a display function that emits the four vertices, and a geometry shader that should loop

for (i = 0; i < gl_VerticesIn; i += 4)
{
a = gl_PositionIn [i];
b = gl_PositionIn [i+1];

}
etc. However, this gives me array index out of bounds errors, and when I try some debugging, it appears that gl_VerticesIn == 1!

The only explanation I can think of is that gl_VerticesIn is misnamed, and it really ought to be called something like gl_VerticesInPrimitive - that is, it’s 1 for points, 2 for lines, etc. But if that’s the case, not only have I wasted a good bit of time discovering it (because I can’t find it documented anywhere), but I’ve no idea how to go about actually doing what I need to do: process groups of 4 vertices.

Any suggestions?

You can use lines with adjacency to have access to 4 vertices of an input primitive.

In the EXT_geometry_shader4 specification, there is a table listing the value of gl_VerticesIn based on input primitive type. Search for Table 4.3.

http://www.opengl.org/registry/specs/EXT/geometry_shader4.txt

Thanks for the reference. I’ve seen it (or similar) before, and have tried to read it, but since it’s mostly snippets of “add to section xxx” I never managed to glean much useful information. I suppose it works for its intended purpose - a reference for implementors - but as an introduction it leaves something to be desired.

I did try the lines with adjacency, and it seems to work for this problem.

Nope, the extension registry is actually very useful, you just have to know where to look. Skip the documentation modifications sections and you’ll find the relevant information.

You can always check the SDK man files, but some of the latest offerings may not have found their way into the fold yet.

P.S. You’ll get used to the reading the specs. If I can get used to them, anyone can.

What man files? I’d like to have some, but on my system (NVidia) there’s nothing beyond standard OpenGL functions as of version 1.4 or so. Not just GLSL, but things like framebuffer object functions…

P.S. You’ll get used to the reading the specs. If I can get used to them, anyone can.

Yeah, they say you can get used to hanging, if you hang long enough :slight_smile:

These man files
http://www.opengl.org/sdk/docs/man/

You can acually build these pages yourself! Check out the wiki over here
http://www.opengl.org/wiki/index.php/Getting_started/XML_Toolchain_and_Man_Pages
for instructions.

I’m sure I didn’t understand all that on a quick readthrough. Maybe when things slow down a bit (I hope!) in a couple of weeks, I’ll have time to puzzle through them. I did note one worrisome comment at the end: “The modular stylesheets include a manpages stylesheet but nobody has tried it yet.” So these are supposed to be man pages, but no one has actually tried generating them?

I did manage to get this to work on Windows, going the Cygwin route (one very dark and lonely night). Curiosity over the toolchain got the best of me.

But I think the comment is referring to the various output format options, not the reference pages themselves.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.