diff --git a/CMakeLists.txt b/CMakeLists.txt index b8b3ddb8f9c7701ec816839d51a761a065fa6bae..29a966663e50c26cf265a44e11d39ad271ffa949 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ set(COMMON_SOURCES common/Linux/MicroGlut.c ) -file(GLOB_RECURSE SRC_SOURCES src/*.cpp src/*.c) +file(GLOB_RECURSE SRC_SOURCES src/*.cpp src/*.c src/*.h) set(SOURCES ${COMMON_SOURCES} ${SRC_SOURCES}) diff --git a/shaders/surface.vert b/shaders/surface.vert index 1296d38ee99cc223e46773830e254513f259d7b3..e970ab79b48682e8b4cb71e6bbe9de279509ea97 100644 --- a/shaders/surface.vert +++ b/shaders/surface.vert @@ -8,6 +8,10 @@ uniform mat4 projectionMatrix; uniform mat4 modelToWorldToView; uniform float time; +// layout(std140) uniform VertexBuffer { +// Wave waves_b[16]; +// }; + out vec3 world_pos; out vec3 normal; @@ -57,7 +61,6 @@ vec3 get_waves(const vec3 pos, const float t) { } return offset + vec3(pos.x, 0.0, pos.z); - } /* Get the normal for a wave */ diff --git a/src/main.cpp b/src/main.cpp index 5ce9d9737f0bd8945db41d84f9c055448c7ef5b8..96ce3227c9365446999c109ca9cc845953793331 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,6 +9,7 @@ #include "LoadTGA.h" #include "MicroGlut.h" #include "VectorUtils4.h" +#include "waves.h" // uses framework OpenGL // uses framework Cocoa @@ -256,6 +257,8 @@ int main(int argc, char* argv[]) glutMotionFunc(on_mouse_move); glutMouseFunc(on_mouse_button); + Waves::init(); + glutMainLoop(); exit(0); } diff --git a/src/waves.cpp b/src/waves.cpp new file mode 100644 index 0000000000000000000000000000000000000000..853d614158f2dacc8ccf230ef498af923dba4cfb --- /dev/null +++ b/src/waves.cpp @@ -0,0 +1,16 @@ +#include <iostream> +#include "waves.h" +#include <GL/gl.h> + + +namespace Waves { + +GLuint ubo; + +void init() { + glGenBuffers(1, &ubo); + glBindBuffer(GL_UNIFORM_BUFFER, ubo); + glBufferData(GL_UNIFORM_BUFFER, sizeof(Wave) * 16, nullptr, GL_DYNAMIC_DRAW); +} + +}; diff --git a/src/waves.h b/src/waves.h new file mode 100644 index 0000000000000000000000000000000000000000..bcf9d2995cb68e64737b7c0af179b68ad5a6b6e7 --- /dev/null +++ b/src/waves.h @@ -0,0 +1,8 @@ +#pragma once + + +namespace Waves { + +void init(); + +};