diff --git a/.idea/editor.xml b/.idea/editor.xml
index 5bf27ce..2f7424b 100644
--- a/.idea/editor.xml
+++ b/.idea/editor.xml
@@ -283,6 +283,7 @@
+
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 309514d..efc4599 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,6 +2,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 62e1407..34f1d31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
-project(gpu-particles VERSION 0.0.5)
+project(gpu-particles VERSION 0.0.6)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
diff --git a/src/main.cpp b/src/main.cpp
index b93fe96..234eb98 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,6 +19,7 @@
#include "blt/gfx/renderer/batch_2d_renderer.h"
#include "blt/gfx/renderer/camera.h"
#include
+#include
#include
#include
#include
@@ -31,17 +32,39 @@ blt::gfx::resource_manager resources;
blt::gfx::batch_renderer_2d renderer_2d(resources, global_matrices);
blt::gfx::first_person_camera camera;
+// use types for state that way you are not confused about what is happening?
+
+class unique_vao_t
+{
+public:
+ unique_vao_t(): vaoID(0)
+ {}
+
+ void create()
+ {
+ #if blt_debug_has_flag(BLT_DEBUG_CONTRACTS)
+ BLT_CONTRACT(!vaoID, "VAO already created");
+ #endif
+
+ vaoID = 0;
+ glGenVertexArrays(1, &*vaoID);
+ }
+
+private:
+ std::optional vaoID;
+};
+
struct particle_t
{
- blt::vec2 position;
- blt::vec2 velocity;
- blt::vec2 acceleration;
+ blt::vec2 position;
+ blt::vec2 velocity;
+ blt::vec2 acceleration;
- static particle_t make_particle()
- {
- blt::random::random_t random{std::random_device()()};
- return {blt::vec2{random.get(0.0f, 500.0f), random.get(0.0f, 500.0f)}, blt::vec2{}, blt::vec2{}};
- }
+ static particle_t make_particle()
+ {
+ blt::random::random_t random{std::random_device()()};
+ return {blt::vec2{random.get(0.0f, 500.0f), random.get(0.0f, 500.0f)}, blt::vec2{}, blt::vec2{}};
+ }
};
std::unique_ptr particle_vao;
@@ -55,53 +78,53 @@ std::vector particles;
void init(const blt::gfx::window_data&)
{
- using namespace blt::gfx;
+ using namespace blt::gfx;
- particle_shader = std::unique_ptr(shader_t::make(shader_particle_2d_vert, shader_particle_2d_frag));
+ particle_shader = std::unique_ptr(shader_t::make(shader_particle_2d_vert, shader_particle_2d_frag));
- for (blt::size_t i = 0; i < PARTICLE_COUNT; i++)
- {
- particles.push_back(particle_t::make_particle());
- alive_particles.push_back(i);
- }
+ for (blt::size_t i = 0; i < PARTICLE_COUNT; i++)
+ {
+ particles.push_back(particle_t::make_particle());
+ alive_particles.push_back(i);
+ }
- particle_vbo = std::make_unique();
- particle_vbo->create(GL_ARRAY_BUFFER);
- particle_vbo->allocate(sizeof(particle_t) * particles.size(), GL_DYNAMIC_DRAW, particles.data());
+ particle_vbo = std::make_unique();
+ particle_vbo->create(GL_ARRAY_BUFFER);
+ particle_vbo->allocate(sizeof(particle_t) * particles.size(), GL_DYNAMIC_DRAW, particles.data());
- alive_particles_ebo = std::make_unique();
- alive_particles_ebo->create();
- alive_particles_ebo->allocate(sizeof(blt::u32) * alive_particles.size(), GL_DYNAMIC_DRAW, alive_particles.data());
+ alive_particles_ebo = std::make_unique();
+ alive_particles_ebo->create();
+ alive_particles_ebo->allocate(sizeof(blt::u32) * alive_particles.size(), GL_DYNAMIC_DRAW, alive_particles.data());
- particle_vao = std::make_unique();
- particle_vao->bindVBO(*particle_vbo, 0, 2, GL_FLOAT, sizeof(particle_t), 0);
- particle_vao->bindElement(*alive_particles_ebo);
+ particle_vao = std::make_unique();
+ particle_vao->bindVBO(*particle_vbo, 0, 2, GL_FLOAT, sizeof(particle_t), 0);
+ particle_vao->bindElement(*alive_particles_ebo);
- global_matrices.create_internals();
- resources.load_resources();
- renderer_2d.create();
+ global_matrices.create_internals();
+ resources.load_resources();
+ renderer_2d.create();
}
void update(const blt::gfx::window_data& data)
{
- global_matrices.update_perspectives(data.width, data.height, 90, 0.1, 2000);
+ global_matrices.update_perspectives(data.width, data.height, 90, 0.1, 2000);
- camera.update();
- camera.update_view(global_matrices);
- global_matrices.update();
+ camera.update();
+ camera.update_view(global_matrices);
+ global_matrices.update();
- renderer_2d.render(data.width, data.height);
+ renderer_2d.render(data.width, data.height);
}
void destroy(const blt::gfx::window_data&)
{
- global_matrices.cleanup();
- resources.cleanup();
- renderer_2d.cleanup();
- blt::gfx::cleanup();
+ global_matrices.cleanup();
+ resources.cleanup();
+ renderer_2d.cleanup();
+ blt::gfx::cleanup();
}
int main()
{
- blt::gfx::init(blt::gfx::window_data{"My Sexy Window", init, update, destroy}.setSyncInterval(1));
-}
\ No newline at end of file
+ blt::gfx::init(blt::gfx::window_data{"My Sexy Window", init, update, destroy}.setSyncInterval(1));
+}