0

I'm trying to draw cube using tessellation and primitive restart index. With using primitive restart index I can reduce index count down to 17, and draw cube with something like this:

glEnable(GL_PRIMITIVE_RESTART);
glPrimitiveRestartIndex(0xFFFF);
glDrawElements(GL_TRIANGLE_STRIP, 17, GL_UNSIGNED_SHORT, NULL);

So, in this case I'm getting strange results, but drawing cube with 36 indices and GL_TRIANGLES type works just fine.

How can I use tessellation with glPrimitiveRestartIndex()?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Peter
  • 435
  • 1
  • 3
  • 11

1 Answers1

0

There is exactly one primitive type allowed for tessellation: GL_PATCHES. So you can't tessellate GL_TRIANGLE_STRIPs. You should have gotten a GL_INVALID_OPERATION error when you rendered.

Every N vertices will be taken as a single patch to be tessellated, where N is defined either by the TCS or by a call to glPatchParameteri(GL_PATCH_VERTICES, N);. This is much like GL_TRIANGLES: every 3 vertices is a triangle. Each patch is completely separate from every other path. So if N is 4, then drawing 8 vertices will generate 2 patches.

This means that there's really no purpose in using primitive restart with tessellation.

genpfault
  • 51,148
  • 11
  • 85
  • 139
Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982