aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-12-16 13:58:20 +0100
committerAdrian Kummerlaender2018-12-16 13:58:20 +0100
commit2eb7f9925315989735b4fb746cbd7bda6c9bd5bb (patch)
tree67e94d6898eac507a8a7c2c6cccf7f875f2979dc /src/main.cc
parent44f5ac32a68a617f93704d44c4339f7db13b323e (diff)
downloadcompustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.gz
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.bz2
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.lz
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.xz
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.tar.zst
compustream-2eb7f9925315989735b4fb746cbd7bda6c9bd5bb.zip
Parametrize lattice resolution
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/main.cc b/src/main.cc
index 914d505..1feb649 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -22,6 +22,9 @@
#include "timer.h"
+constexpr GLuint nX = 128;
+constexpr GLuint nY = 128;
+
float getWorldHeight(int window_width, int window_height, float world_width) {
return world_width / window_width * window_height;
}
@@ -53,7 +56,7 @@ int renderWindow() {
int window_width = window.getWidth();
int window_height = window.getHeight();
- float world_width = 256.0;
+ float world_width = 2*nX;
float world_height = getWorldHeight(window_width, window_height, world_width);
glm::mat4 MVP = getMVP(world_width, world_height);
@@ -71,12 +74,12 @@ int renderWindow() {
scene_shader = std::make_unique<GraphicShader>(
VERTEX_SHADER_CODE, FRAGMENT_SHADER_CODE);
- lattice_buffer_a = std::make_unique<LatticeCellBuffer>();
- lattice_buffer_b = std::make_unique<LatticeCellBuffer>();
- fluid_buffer = std::make_unique<FluidCellBuffer>();
+ lattice_buffer_a = std::make_unique<LatticeCellBuffer>(nX, nY);
+ lattice_buffer_b = std::make_unique<LatticeCellBuffer>(nX, nY);
+ fluid_buffer = std::make_unique< FluidCellBuffer>(nX, nY);
collide_shader = std::make_unique<ComputeShader>(COLLIDE_SHADER_CODE);
- stream_shader = std::make_unique<ComputeShader>(STREAM_SHADER_CODE);
+ stream_shader = std::make_unique<ComputeShader>(STREAM_SHADER_CODE);
});
if ( !collide_shader->isGood() || !stream_shader->isGood() ) {
@@ -107,7 +110,7 @@ int renderWindow() {
}
if ( update_lattice ) {
- if ( timer::millisecondsSince(last_frame) >= 1000/25 ) {
+ if ( timer::millisecondsSince(last_frame) >= 1000/50 ) {
if ( tick ) {
collide_shader->workOn(lattice_buffer_a->getBuffer(), lattice_buffer_b->getBuffer(), fluid_buffer->getBuffer());
stream_shader->workOn(lattice_buffer_a->getBuffer(), lattice_buffer_b->getBuffer(), fluid_buffer->getBuffer());
@@ -120,11 +123,11 @@ int renderWindow() {
{
auto guard = collide_shader->use();
- collide_shader->dispatch();
+ collide_shader->dispatch(nX, nY);
}
{
auto guard = stream_shader->use();
- stream_shader->dispatch();
+ stream_shader->dispatch(nX, nY);
}
last_frame = timer::now();