From 7d1d4ff56eef3753b11a69ea02e53d2a9d9a4267 Mon Sep 17 00:00:00 2001 From: Brett Date: Sun, 8 Jun 2025 13:00:14 -0400 Subject: [PATCH] test --- CMakeLists.txt | 2 +- commit.py | 2 +- src/main.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 56 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34f1d31..628e9ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(gpu-particles VERSION 0.0.6) +project(gpu-particles VERSION 0.0.8) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/commit.py b/commit.py index b885026..2af4749 100755 --- a/commit.py +++ b/commit.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!python3 import subprocess import argparse diff --git a/src/main.cpp b/src/main.cpp index 234eb98..46e4c01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -34,22 +34,68 @@ blt::gfx::first_person_camera camera; // use types for state that way you are not confused about what is happening? +class unique_vbo_t +{ +public: + explicit unique_vbo_t(const GLuint type): type(type) + { + glGenBuffers(1, &*vboID); + } + + unique_vbo_t(const unique_vbo_t&) = delete; + + unique_vbo_t& operator=(const unique_vbo_t&) = delete; + + unique_vbo_t(unique_vbo_t&& other) noexcept: vboID(std::exchange(other.vboID, std::nullopt)), type(other.type) + { + } + + unique_vbo_t& operator=(unique_vbo_t&& other) noexcept + { + vboID = std::exchange(other.vboID, vboID); + type = std::exchange(other.type, type); + return *this; + } + + ~unique_vbo_t() + { + if (vboID) + glDeleteBuffers(1, &*vboID); + } + +private: + std::optional vboID; + GLuint type; +}; + 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); } + unique_vao_t(const unique_vao_t&) = delete; + + unique_vao_t& operator=(const unique_vao_t&) = delete; + + unique_vao_t(unique_vao_t&& other) noexcept: vaoID(std::exchange(other.vaoID, std::nullopt)) + { + } + + unique_vao_t& operator=(unique_vao_t&& other) noexcept + { + vaoID = std::exchange(other.vaoID, vaoID); + return *this; + } + + ~unique_vao_t() + { + if (vaoID) + glDeleteVertexArrays(1, &*vaoID); + } + private: std::optional vaoID; };