Creating a Geometry Shader
Geometry shaders are created in exactly the same manner as any other type of shader—by using the glCreateShader() function. To create a geometry shader, pass GL_GEOMETRY_SHADER as the shader type parameter to glCreateShader(). The shader source is passed as normal using the glShaderSource() function and then the shader is compiled using glCompileShader(). Multiple geometry shaders may be attached to a single program object and when that program is linked, the attached geometry shaders will be linked into an executable that can run on the GPU. When a program object containing a geometry shader is active the geometry shader will run on each primitive produced by OpenGL. These primitives may be points, lines, triangles ...
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.