OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition
by Dave Shreiner, Graham Sellers, John M. Kessenich, Bill M. Licea-Kane
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access