36 lines
957 B
C
36 lines
957 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 {
|
|
int gridW;
|
|
int gridH;
|
|
GLuint tex_curr;
|
|
GLuint tex_next;
|
|
GLuint tex_claim; // NEW: claim buffer
|
|
GLuint prog_sim;
|
|
GLuint prog_paint;
|
|
GLuint prog_relax;
|
|
} 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);
|
|
void sand_relax_gpu(SandSim* sim);
|
|
// Destroy all GL objects owned by the sim.
|
|
void sand_destroy(SandSim* sim);
|
|
void sand_paint_gpu(SandSim* sim,
|
|
float brushX,
|
|
float brushY,
|
|
float brushRadius,
|
|
int mode);
|
|
#endif // SAND_SIM_H
|