Geometry Shader Redux

To use a geometry shader in your program:

• Create a geometry shader with glCreateShader(GL_GEOMETRY_SHADER).

• Set the shader source with glShaderSource and compile it with glCompileShader.

• Attach it to a program object with glAttachShader, and link the program with glLinkProgram.

Inside your geometry shader do the following:

• Specify input and output primitive types with the layout (<primitive_type>) in ; or layout (<primitive_type>) out ; layout qualifiers.

• Specify the maximum number of vertices the shader might produce with the layout (max_vertices = <vertex_count>) in ; layout qualifier.

• Declare all inputs to the geometry shader as arrays (using the in keyword). You can use the .length() method on the input arrays ...

Get OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth 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.