OiO.lk Blog java Does LibGDX support Primitive Restarts for Triangle Fans in Mesh Indices?
java

Does LibGDX support Primitive Restarts for Triangle Fans in Mesh Indices?


OpenGL supports the ability to start a new Triangle Strip in an index array by inserting two duplicate indices, (what they call a "degenerate triangle"), like this:

GLuint idxs[] = {0, 1, 2, 3, 3, 4, 4, 5, 6, 7};

And it supports a similar ability to start a new Triangle Fan in an index array by defining and inserting a Primitive Restart index, like this:

GLuint PRIMITIVE_RESTART = 12345; // magic value
glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(PRIMITIVE_RESTART);
GLuint idxs[] = {0, 1, 2, 3, PRIMITIVE_RESTART, 4, 5, 6, 7};

That’s nice, but I’m using LibGdx.

LibGdx supports the Degenerate Triangle technique for Triangle Strips, but does it support Primitive Restarts for Triangle Fans as well?

I get the benefit of optimizing GPU IO traffic by cramming as much data into as small a mesh as possible by reusing vertices that are referenced by multiple indices and using triangle strips and fans rather than a bunch of single triangles. All of which is better than composing a lot of small meshes rendering one triangle, strip, or fan at a time.

I am tessellating a large region of space with Triangle Fans, and I want to cram a TON of them into a single mesh. Is that possible? Or am I going to have to resort to breaking the fans down into individual triangles? A mesh is composed of only one array of vertices and one array of indices, right? And a mesh can’t reference vertices from a different mesh, right? So it seems like my solution has to be in the indices array.



You need to sign in to view this answers

Exit mobile version