aboutsummaryrefslogtreecommitdiff
path: root/src/shader
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader')
-rw-r--r--src/shader/code/collide.glsl10
-rw-r--r--src/shader/wrap/compute_shader.cc12
-rw-r--r--src/shader/wrap/compute_shader.h3
3 files changed, 20 insertions, 5 deletions
diff --git a/src/shader/code/collide.glsl b/src/shader/code/collide.glsl
index 78d3936..2626c70 100644
--- a/src/shader/code/collide.glsl
+++ b/src/shader/code/collide.glsl
@@ -7,6 +7,10 @@ layout (std430, binding=1) buffer bufferCollide{ float collideCells[]; };
layout (std430, binding=2) buffer bufferStream{ float streamCells[]; };
layout (std430, binding=3) buffer bufferFluid{ float fluidCells[]; };
+uniform int mouseClicked;
+uniform int mouseX;
+uniform int mouseY;
+
/// LBM constants
uniform uint nX;
@@ -103,7 +107,11 @@ void main() {
return;
}
- const float d = density(x,y);
+ float d = density(x,y);
+ if ( mouseClicked == 1 && abs(x - mouseX) < 3 && abs(y - mouseY) < 3 ) {
+ d = 1.5;
+ }
+
const vec2 v = velocity(x,y,d);
setFluid(x,y,v,d);
diff --git a/src/shader/wrap/compute_shader.cc b/src/shader/wrap/compute_shader.cc
index 54f50f8..134db2d 100644
--- a/src/shader/wrap/compute_shader.cc
+++ b/src/shader/wrap/compute_shader.cc
@@ -34,18 +34,24 @@ bool ComputeShader::isGood() const {
return _good;
}
-GLuint ComputeShader::setUniform(const std::string& name, float x, float y) const {
+GLuint ComputeShader::setUniform(const std::string& name, int value) const {
GLuint id = util::getUniform(_id, name);
- glUniform2f(id, x, y);
+ glUniform1i(id, value);
return id;
}
-GLuint ComputeShader::setUniform(const std::string& name, unsigned int value) const {
+GLuint ComputeShader::setUniform(const std::string& name, GLuint value) const {
GLuint id = util::getUniform(_id, name);
glUniform1ui(id, value);
return id;
}
+GLuint ComputeShader::setUniform(const std::string& name, float x, float y) const {
+ GLuint id = util::getUniform(_id, name);
+ glUniform2f(id, x, y);
+ return id;
+}
+
void ComputeShader::workOn(const std::vector<GLuint>& buffers) const {
glBindBuffersBase(GL_SHADER_STORAGE_BUFFER, 1, buffers.size(), buffers.data());
}
diff --git a/src/shader/wrap/compute_shader.h b/src/shader/wrap/compute_shader.h
index f2ab182..d7ef729 100644
--- a/src/shader/wrap/compute_shader.h
+++ b/src/shader/wrap/compute_shader.h
@@ -26,8 +26,9 @@ public:
bool isGood() const;
+ GLuint setUniform(const std::string& name, int value) const;
+ GLuint setUniform(const std::string& name, GLuint value) const;
GLuint setUniform(const std::string& name, float x, float y) const;
- GLuint setUniform(const std::string& name, unsigned int value) const;
void workOn(const std::vector<GLuint>& buffers) const;