summaryrefslogtreecommitdiff
path: root/src/effects/particles_effect.h
blob: 174a6c7dbd25dcf2363211fc5a45b0ec9a1b69a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// This file is part of the 64k demo project.
// It declares the ParticlesEffect.

#pragma once

#include "gpu/effect.h"
#include "gpu/gpu.h"
#include "gpu/uniform_helper.h"
#include <vector>

// Particle structure
static const int NUM_PARTICLES = 10000;

struct Particle {
  float pos[4];
  float vel[4];
  float rot[4];
  float color[4];
};

class Particles : public Effect {
 public:
  Particles(const GpuContext& ctx,
                    const std::vector<std::string>& inputs,
                    const std::vector<std::string>& outputs);
  void render(WGPUCommandEncoder encoder,
              const UniformsSequenceParams& params,
              NodeRegistry& nodes) override;

 private:
  ComputePass compute_pass_;
  RenderPass render_pass_;
  GpuBuffer particles_buffer_;
  UniformBuffer<UniformsSequenceParams> uniforms_;
};