Problem with degenerate triangles and GL_TRIANGLE_STRIP
Asked Answered
B

1

9

I'm trying to draw multiple triangle strips with only one call to glDrawElements and my research on the matter tells me I need to use degenerate triangles. Maybe my understanding on the subject is wrong but I thought this should allow me to "jump" from a strip to another.

My whole code for this can be found on this recent question I posted, take a look there if you think it's relevant.

I'm basically trying to draw 2 quads(for simplification purposes) with 4 triangles of course, but separated from each other. For that I use indices like this:

unsigned int indices[] = { 0, 256, 1, 257, 257, 2, 2, 258, 3, 259 };

The first vertex of the first strip starts at 0 and the first vertex of the second strip starts at 256. This is the end result of this indices:

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfpKnMxcF_AZVLQamyA/6Q3FD.jpg

Is this correct or am I right in thinking that line "connecting" the 2 quads shouldn't be there at all?

Bast answered 25/4, 2011 at 4:13 Comment(1)
Note that if you run on an OpenGL 3.1 capable card, you can use primitive restart to the same effect, but with less trouble. It works by inserting a special (unused, configurable) index that makes the GL start a new primitive.Welbie
M
8

The image shown is correct. This trick doesn't work for wireframes. If you were drawing filled triangles, the triangle with zero area wouldn't show up, but you're drawing outlines.

Matchwood answered 25/4, 2011 at 4:31 Comment(1)
Interesting, it's true lol. The wire-frame was just for testing purposes, it's easier to see if the mes is well built, I was just unaware of this little quirk.Bast

© 2022 - 2024 — McMap. All rights reserved.