Chap1TransformFeedback is sample C++ code illustrating the use of Modern OpenGL. It 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 code was used to help generate images such as these two spheres:
Chap1TransformFeedback illustrates the use of a Transform Feedback Buffer to allow data that calculated by a a shader program be accessed by the calling C++ program. Chap1TransformFeedback uses a geometry shader to calculate the Transform Feedback Buffer data, but it is also possible to use a vertex shader or a tessellation shader instead. The part of the code that handles the Transform Feedback consists of two core source files, Chap1TransformFeedback.cpp and Chap1TransformFeedback.h, and two files of GLSL shader programs, XformFeedbackChap1.glsl and XformShader.glsl. There are also two specialized files PstricksOutdata.cpp and PstricksOutdata.cpp that use the contents of the Transform Feedback Buffer to generate LaTeX pstricks commands for a couple of figures in Chapter 1 of the text, It also uses GlShaderMgr.cpp and GlShaderMgr.h; these are part of the GlShaderMgr software package. In addition it uses programs from the GlGeomShapes package to render spheres, tori and cylinders. Finally, it uses the GlLinearMath files LinearR3.[cpp,h], LinearR4.[cpp,h], and MathMisc.h.
For information on how to program Transform Feedback in a C++ program with GLSL shaders, see the description of how Transform Feedback is implemented in Chap1TransformFeedback.To download the Chap1TransformFeedback files:
GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN
query to
learn the number of records contained in the Transform Feedback Buffer.
glEnable(GL_RASTERIZER_DISCARD)
and glDisable(GL_RASTERIZER_DISCARD)
to have a shader program that
does not use a fragment shader.
Version 1.0 of Chap1TransformFeedback, May 29, 2019. Updated: May 22, 2020.