28 lines
746 B
C
28 lines
746 B
C
// sand_sim.h
|
|
#ifndef SAND_SIM_H
|
|
#define SAND_SIM_H
|
|
|
|
#include <stdbool.h>
|
|
#include "glad/glad.h"
|
|
|
|
// Simple binary sand vs air simulation
|
|
typedef struct {
|
|
GLuint tex_curr; // R8UI; 0 = air, 1 = sand
|
|
GLuint tex_next; // R8UI; ping-pong target
|
|
GLuint prog_sim; // compute shader program
|
|
int gridW;
|
|
int gridH;
|
|
} SandSim;
|
|
|
|
// Initialize sim, allocate textures, upload initial state, load compute shader.
|
|
// Returns true on success, false on failure.
|
|
bool sand_init(SandSim* sim, int gridW, int gridH, const char* computeShaderPath);
|
|
|
|
// Advance simulation by 1 discrete tick (one CA step).
|
|
void sand_step_gpu(SandSim* sim);
|
|
|
|
// Destroy all GL objects owned by the sim.
|
|
void sand_destroy(SandSim* sim);
|
|
|
|
#endif // SAND_SIM_H
|