summaryrefslogtreecommitdiff
path: root/themes/src/Snowflake.h
blob: 02673c1f54c3ebca9e0248d0c9ba4120ea15a450 (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
37
38
39
40
41
42
43
44
45
#include "types.h"
#include "mathlib.h"
#include "list.h"

struct Renderer2d;
struct Vertex2D;

struct SnowflakeLoadParameters {
	i32 numSnowflakes = 500;
	f32 rateOfSnowfall = 0.1f;
    Vector2 flakeV0 = { 0, 1 };
	Vector4 snowColor = { 0.8, 0.8, 0.8, 1.0 };
	f32 windIntervalSeconds = 1.5;
};

struct SnowflakeUpdateData {
	Vector2 v0;
	Vector2 velocity;
	Vector2 position;
    f32 rotateVelocity = 0.f;
	f32 rotation = 0;

	i32 vtxIdx = 0;
	i32 numVertices = 0;
};

struct SnowflakeParticleRenderer {
	f32 xMax = 0;
	f32 yMax = 0;
	f32 windIntervalSeconds = 1.5;
	i32 numSnowflakes = 0;
    Vector2 windSpeed;
	SnowflakeUpdateData* updateData;
	f32 timeUntilNextWindSeconds = 0;

	u32 vao;
	u32 vbo;
	Mat4x4 model;
	matte::List<Vertex2D> vertices;
	
	void load(SnowflakeLoadParameters params, Renderer2d* renderer);
	void update(f32 dtSeconds);
	void render(Renderer2d* renderer);
	void unload();
};