I would really like to stick to OpenGL only
I have been thinking of ways that I could achieve what I'm trying to do and I wanted to know everyone's thoughts on them
Now, I'm strictly talking about the update side of things here as the rendering part is taken care of.
Conditions
1. Ability to generate X particles every Y seconds
2. Lots and lots of particles. Have as many as I can
3. Particles have textures and attributes like position, lifetime, size, etc
Idea 1
Use a pass through Vertex Shader with a Geometry Shader. Where the Geometry Shader takes in GL_POINTS and spits back out GL_POINTS. In this case the Geometry Shader would be the one responsible for updating the particles. (Might be faster to update in Vertex Shader and then check if I need to discard in the Geometry Shader. Thoughts?) In addition it only generates new particles through the EmitVertex and EndPrimative calls when the generation time has been hit
Pros:
Should be able to allow me to do what I want
Particles "die" and "are created" on the fly
Cons:
Have to use a Geometry shader
Only can emit out MAX_GEOMETRY_OUTPUT_VERTICES (For me this is 1024, lowest it must be is 32)
[Might be able to get past above. Could do multiple updates. If I need to use more than the MAX_GEOMETRY_OUTPUT_VERTICES just write into another part of the buffer or a different buffer all together]
Idea 2
Create all the particles that I would ever need and keep a copy of my particles on the CPU side.
When it comes time to "generate" particles, check which particles are "dead" and reset there lifetime using glBufferSubData on the whole buffer (since I dont think multiple glBufferSubData for "dead" particles only would be good). Then afterwards, my buffer gets sent to the Vertex Shader where they get updated. After the update in the Vertex Shader, I save the results back into my CPU's particle copy
Pros:
Should be able to allow me to do what I want
Should be able to have as many particles as my hardware can handle
Cons:
Might be super slow since I'm pretty sure I need to read back / save the transform feedback buffer
The more particles I have the slower it gets
Idea 3
Keep everything as it is and have a global counter to reset the lifetimes of dead particles. When the Vertex Shader runs, check if the "generate particles" flag has been set to true. If so, then revive the particles that are dead and repeat this until counter has met the "number to revive count". Continue on updating the particles
Pros:
Should be able to allow me to do what I want
Should be able to have as many particles as my hardware can handle
Cons:
I don't think this (a global counter) is possible with the current version of OpenGL I am targeting?