-
Notifications
You must be signed in to change notification settings - Fork 1
/
FluidRenderer2D.h
96 lines (76 loc) · 2.01 KB
/
FluidRenderer2D.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// Created by lasagnaphil on 10/2/18.
//
#ifndef FLUID_SIM_FLUIDRENDERER2D_H
#define FLUID_SIM_FLUIDRENDERER2D_H
#include <glad/glad.h>
#include <StackVec.h>
#include <imgui.h>
#include "Shader.h"
#include "FluidSim2D.h"
#include "FirstPersonCamera.h"
#include "InputManager.h"
#include "Camera2D.h"
static float origQuadVertices[12] = {
0.0f, 0.0f,
0.0f, 1.0f,
1.0f, 1.0f,
0.0f, 0.0f,
1.0f, 1.0f,
1.0f, 0.0f,
};
struct FluidRenderer2D {
int sizeX;
int sizeY;
int particlesPerCellSqrt;
int particlesPerCell;
GLuint waterCellVAO;
GLuint solidCellVAO;
GLuint cellVelVAO;
GLuint pressureCellVAO;
GLuint phiCellVAO;
GLuint particleVAO;
GLuint particleVelVAO;
GLuint quadVBO;
GLuint waterCellOffsetVBO;
GLuint solidCellOffsetVBO;
GLuint cellVelVBO;
GLuint pressureCellOffsetVBO;
GLuint pressureCellValueVBO;
GLuint allCellOffsetVBO;
GLuint phiCellValueVBO;
GLuint particleVBO;
GLuint particleVelVBO;
vec2f quadVertices[6];
Vec<vec2f> waterCellLocations = {};
Vec<vec2f> solidCellLocations = {};
Vec<vec2f> pressureCellLocations = {};
Vec<vec2f> cellVels = {};
Vec<float> pressureCellValues = {};
Vec<vec2f> allCellLocations = {};
Vec<float> phiCellValues = {};
Vec<vec2f> particleVelLines = {};
Shader cellShader;
Shader particleShader;
Shader cellFieldShader;
FluidSim2D* sim;
Camera2D* camera;
bool renderParticles = true;
bool renderParticleVels = true;
bool renderCells = true;
bool renderCellVels = false;
bool renderPressures = false;
bool renderLevelSet = false;
static const char* particleVS;
static const char* cellVS;
static const char* cellFieldVS;
static const char* cellFS;
static FluidRenderer2D create(FluidSim2D* sim, Camera2D* camera);
void free();
void setup();
void update();
void draw();
void drawUI();
void updateBuffers();
};
#endif //FLUID_SIM_FLUIDRENDERER2D_H