diff --git a/CMakeLists.txt b/CMakeLists.txt index 98fc594..d4c64aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(gpu-particles VERSION 0.0.3) +project(gpu-particles VERSION 0.0.4) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/include/shaders/particle.frag b/include/shaders/particle.frag index e69de29..96d01a4 100644 --- a/include/shaders/particle.frag +++ b/include/shaders/particle.frag @@ -0,0 +1,18 @@ +#ifdef __cplusplus +#include +const std::string shader_particle_2d_frag = R"(" +#version 300 es +precision mediump float; + +layout (location = 0) in vec4 position_uv; + +out vec2 UVs; + +void main() +{ + gl_Position = vec4(position_uv.x, position_uv.y, 0.0, 1.0); + UVs = position_uv.zw; +} + +")"; +#endif \ No newline at end of file diff --git a/include/shaders/particle.vert b/include/shaders/particle.vert index b079795..8de5756 100644 --- a/include/shaders/particle.vert +++ b/include/shaders/particle.vert @@ -1,6 +1,6 @@ #ifdef __cplusplus #include -const std::string shader_2d_font_frag = R"(" +const std::string shader_particle_2d_vert = R"(" #version 300 es precision mediump float; diff --git a/src/main.cpp b/src/main.cpp index d8f9302..b0f6737 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,8 @@ #include "blt/gfx/renderer/resource_manager.h" #include "blt/gfx/renderer/batch_2d_renderer.h" #include "blt/gfx/renderer/camera.h" +#include +#include #include blt::gfx::matrix_state_manager global_matrices; @@ -32,10 +34,10 @@ struct particle_t blt::vec2 acceleration; }; -blt::gfx::vertex_array_t particle_vao; -blt::gfx::vertex_buffer_t particle_vbo; -blt::gfx::element_buffer_t alive_particles_ebo; -blt::gfx::shader_t particle_shader{}; +std::unique_ptr particle_vao; +std::unique_ptr particle_vbo; +std::unique_ptr alive_particles_ebo; +std::unique_ptr particle_shader; std::vector alive_particles; std::vector dead_particles; @@ -45,6 +47,7 @@ void init(const blt::gfx::window_data&) { using namespace blt::gfx; + particle_shader = std::unique_ptr(shader_t::make(shader_particle_2d_vert, shader_particle_2d_frag)); global_matrices.create_internals(); resources.load_resources();