How to do it...

To create a shader program that creates Bezier patches from input patches of 16 control points, use the following steps:

  1. Use the vertex shader from the Tessellating a 2D quad recipe.
  2. Use the following code for the tessellation control shader:
layout( vertices=16 ) out; 
 
uniform int TessLevel; 
 
void main() {
    // Pass along the vertex position unmodified 
    gl_out[gl_InvocationID].gl_Position =  
                 gl_in[gl_InvocationID].gl_Position; 
 
    gl_TessLevelOuter[0] = float(TessLevel); 
    gl_TessLevelOuter[1] = float(TessLevel); 
    gl_TessLevelOuter[2] = float(TessLevel); 
    gl_TessLevelOuter[3] = float(TessLevel); 
 
    gl_TessLevelInner[0] = float(TessLevel); 
    gl_TessLevelInner[1] = float(TessLevel); 
}
  1. Use the following code for the tessellation evaluation ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.