rare variant

main
Brett 2025-06-07 01:38:54 -04:00
parent 0ae9162c5e
commit c2ed1dec40
4 changed files with 27 additions and 6 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) 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_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -0,0 +1,18 @@
#ifdef __cplusplus
#include <string>
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

View File

@ -1,6 +1,6 @@
#ifdef __cplusplus #ifdef __cplusplus
#include <string> #include <string>
const std::string shader_2d_font_frag = R"(" const std::string shader_particle_2d_vert = R"("
#version 300 es #version 300 es
precision mediump float; precision mediump float;

View File

@ -18,6 +18,8 @@
#include "blt/gfx/renderer/resource_manager.h" #include "blt/gfx/renderer/resource_manager.h"
#include "blt/gfx/renderer/batch_2d_renderer.h" #include "blt/gfx/renderer/batch_2d_renderer.h"
#include "blt/gfx/renderer/camera.h" #include "blt/gfx/renderer/camera.h"
#include <shaders/particle.frag>
#include <shaders/particle.vert>
#include <imgui.h> #include <imgui.h>
blt::gfx::matrix_state_manager global_matrices; blt::gfx::matrix_state_manager global_matrices;
@ -32,10 +34,10 @@ struct particle_t
blt::vec2 acceleration; blt::vec2 acceleration;
}; };
blt::gfx::vertex_array_t particle_vao; std::unique_ptr<blt::gfx::vertex_array_t> particle_vao;
blt::gfx::vertex_buffer_t particle_vbo; std::unique_ptr<blt::gfx::vertex_buffer_t> particle_vbo;
blt::gfx::element_buffer_t alive_particles_ebo; std::unique_ptr<blt::gfx::element_buffer_t> alive_particles_ebo;
blt::gfx::shader_t particle_shader{}; std::unique_ptr<blt::gfx::shader_t> particle_shader;
std::vector<blt::u32> alive_particles; std::vector<blt::u32> alive_particles;
std::vector<blt::u32> dead_particles; std::vector<blt::u32> dead_particles;
@ -45,6 +47,7 @@ void init(const blt::gfx::window_data&)
{ {
using namespace blt::gfx; using namespace blt::gfx;
particle_shader = std::unique_ptr<shader_t>(shader_t::make(shader_particle_2d_vert, shader_particle_2d_frag));
global_matrices.create_internals(); global_matrices.create_internals();
resources.load_resources(); resources.load_resources();