SimpleGeometryShader contains two examples of Geometry Shader programs. This is part of a set of programs introducing the use of Modern OpenGL, which are intended to accompany a possible second edition of the book 3D Computer Graphics: A mathematical approach with OpenGL, Cambridge University Press, 2003.

The geometry shaders in SimpleGeometryShader take triangles as input, and output triangle strips. One of them shrinks the size of the triangle on the screen. The second geometry shader renders the triangle as three subtriangles making the center of the input triangle white.

         

There are two new sources: the main C++ program SimpleGeometryShader.cpp,, and the GLSL shader code in the file SimpleGeometryShader.glsl. It also requires the GlShaderMgr routines to read, compile and link the shader programs.

Available for download:

Things to try out:

  1. Compile and run the program.
  2. Press the space bar to cycle through the three images. The first is rendered by shader program that does not use a geometry shader. The second is rendered using the geometry shader that shrinks the size of the triangle. The third is is rendered using the geometry shader that splits the triangle into three triangles and makes the center point white.
  3. Read the online documentation of the geometry shader code.

Version 0.1 of SimpleGeometryShader, April 30, 2020. Copyrights reserved.