DrawingGL 4.0
glPatchParameteri
Sets how many vertices make one patch, the primitive that tessellation shaders work on.
Signature
void glPatchParameteri(GLenum pname, GLint value);
How it works
With tessellation shaders in the program you draw with mode GL_PATCHES, and the vertices are grouped into patches of this size instead of triangles. A terrain made of quads uses 4; a curved surface from a 4×4 Bézier grid uses 16. The tessellation control shader receives exactly that many vertices in gl_in.
Parameters
pnameGLenum
GL_PATCH_VERTICES.
valueGLint
Vertices per patch: default 3, up to GL_MAX_PATCH_VERTICES (at least 32).
Tips & pitfalls
Drawing GL_PATCHES without tessellation shaders, or GL_TRIANGLES with them, is GL_INVALID_OPERATION.
count in the draw call should be a multiple of the patch size.
Errors
When the call is invalid it does nothing and sets an error, which glGetError returns:
- GL_INVALID_VALUE
- value is 0 or larger than GL_MAX_PATCH_VERTICES.
Example
example.cpp
1glPatchParameteri(GL_PATCH_VERTICES, 4); // one quad per patch
2glDrawArrays(GL_PATCHES, 0, 4 * patchCount);