Compare commits

..

No commits in common. "9e62497cae142af4a988a06f369ace0a282a0a4e" and "43303bc19a3dd058cf1ea6f45082ef19c0e999f6" have entirely different histories.

4 changed files with 8 additions and 106 deletions

View File

@ -287,7 +287,5 @@
<option name="/Default/CodeStyle/CppIncludeDirective/SortIncludeDirectives/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CppIncludeDirective/UseAngleBracketsInsteadOfQuotes/@EntryValue" value="WhenPossible" type="string" />
<option name="/Default/CodeStyle/CppIncludeDirective/UseRelativePaths/@EntryValue" value="Never" type="string" />
<option name="/Default/CodeStyle/Generate/=CppDefinitions/@KeyIndexDefined" value="true" type="bool" />
<option name="/Default/CodeStyle/Generate/=CppDefinitions/Options/=GenerateInlineDefinitions/@EntryIndexedValue" value="False" type="string" />
</component>
</project>

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25)
project(gpu-particles VERSION 0.0.9)
project(gpu-particles VERSION 0.0.6)
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)

View File

@ -1,4 +1,4 @@
#!python3
#!/usr/bin/python3
import subprocess
import argparse

View File

@ -34,116 +34,20 @@ blt::gfx::first_person_camera camera;
// use types for state that way you are not confused about what is happening?
class unique_vbo_t;
namespace detail
{
class vbo_context_t
{
public:
explicit vbo_context_t(unique_vbo_t& vbo): vbo(vbo)
{
bind();
}
/**
* By default, the VBO is bound when this class is constructed (this class should only be constructed through the VBO bind() method)
* This function is provided in case you need to rebind the VBO
*/
vbo_context_t& bind();
vbo_context_t& unbind();
private:
unique_vbo_t& vbo;
};
}
class unique_vbo_t
{
friend class detail::vbo_context_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;
}
GLuint change_type(const GLuint type)
{
return std::exchange(this->type, type);
}
[[nodiscard]] auto bind()
{
return detail::vbo_context_t{*this};
}
~unique_vbo_t()
{
if (vboID)
glDeleteBuffers(1, &*vboID);
}
private:
std::optional<GLuint> vboID;
GLuint type;
};
namespace detail
{
vbo_context_t& vbo_context_t::bind()
{
glBindBuffer(vbo.type, *vbo.vboID);
return *this;
}
vbo_context_t& vbo_context_t::unbind()
{
glBindBuffer(vbo.type, 0);
return *this;
}
}
class unique_vao_t
{
public:
unique_vao_t(): 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
void create()
{
vaoID = std::exchange(other.vaoID, vaoID);
return *this;
}
#if blt_debug_has_flag(BLT_DEBUG_CONTRACTS)
BLT_CONTRACT(!vaoID, "VAO already created");
#endif
~unique_vao_t()
{
if (vaoID)
glDeleteVertexArrays(1, &*vaoID);
vaoID = 0;
glGenVertexArrays(1, &*vaoID);
}
private: