Hi guys, I’m new here!
I’m coding with C, and I want to do a gravitational particles simulator.
I want to plot cartesian points and update their coordinates continuously, creating a animation.
I have no idea how to do this, I just know how to plot point with GL_POINTS, and have that:
Finally, this one is a bit old, but might be interesting for you since it uses glVertex and so on. It also uses textures so that you can make your particles don’t look like only like colored pixels… For this one don’t pay attention on how it sets the windowing, keep using glut.
get familliar with “vertex array object” and “buffer object” if you want a efficient way to render things (like particles)
to update / animate the particle system, there are different ways to do that:
– you update each particle in your c-application, which is not efficient
– you update the particles in your openGL shader code, thats the approach i would recommend
here is an good example:
web.engr.oregonstate.edu/~mjb/cs557/Handouts/compute.shader.1pp.pdf
no, updating the particles using the graphics card is much faster than doing it on the CPU
rendering and updating are 2 separate steps:
– use a “compute shader” to calculate the new particle attributes (position/velocity/color/lifetime/etc.)
– use a simple vertex/fragment shader to render colored points
Or if you want to target earlier versions of OpenGL (compute shaders were added in 4.3), you can achieve the same result with a vertex shader and transform feedback.
Or, if you’re animating points along a fixed trajectory, you can just compute the position in the vertex shader during rendering. Transform feedback just allows you to save the updated state for use in the next frame.
Separating update from rendering is useful mainly if you’re updating incrementally and there are relatively complex interactions between particles requiring multiple steps and intermediate data structures.