Class ParticleBuffer

java.lang.Object
gaiasky.util.gdx.buffer.ParticleBuffer

public class ParticleBuffer extends Object
A particle buffer to hold particles generated with a ComputeShaderProgram.

Here is a usage example:

ParticleBuffer particleBuffer = new ParticleBuffer(100_000);

// Bind to shader (layout(binding = 0))
particleBuffer.bind(0);

computeShader.bind();
computeShader.setUniform("seed", 1234);
computeShader.setUniform("count", 100_000);
computeShader.setUniform("radius", 1.0f);

int groups = (100_000 + 255) / 256;
glDispatchCompute(groups, 1, 1);
glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);

  • Constructor Details

    • ParticleBuffer

      public ParticleBuffer(int numParticles)
  • Method Details

    • bind

      public void bind(int binding)
      Bind the buffer to a given binding point (matching GLSL layout(binding=X))
    • getData

      public FloatBuffer getData()
      Read back the buffer data (optional, slower)
    • unmap

      public void unmap()
      Unmap buffer after read
    • getId

      public int getId()
    • cleanup

      public void cleanup()