ParticlesTransformFeedback 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.
ParticlesTransformFeedback illustrates the use of a Transform Feedback Buffer to update a large scale particle system. The particles undergo a simple physics simulation based on a gravitational attraction towards the mouse. The image above shows part of a simulation of 4,000,000 particles attracted towards the moving white square.
For information on how this program uses Transform Feedback in a C++ program with GLSL shaders, see the description of how Transform Feedback is implemented in ParticlesTransformFeedback.The part of the code that handles the Transform Feedback consists of a single C++ source file, ParticlesTransformFeedback.cpp, and one of GLSL shader code, ParticlesTransformFeedback.glsl. It also uses GlShaderMgr.cpp and GlShaderMgr.h; these are part of the GlShaderMgr software package.To download the ParticlesTransformFeedback files:
N
. Change this value to be smaller than
2000 to see a smaller field of particles, namely NxN many particles.
glDrawTransformFeedback
render the correct
number of particles from the Transform Feedback Buffer.
glEnable(GL_RASTERIZER_DISCARD)
.
Instead it both perform transform feedback, and renders, in a single
shader program.
gl_PointSize
to set the size of points when drawing
with GL_POINTS
.
Version 1.0 of ParticlesTransformFeedback. Last updated, May 22, 2020.