more test
parent
7d1d4ff56e
commit
9e62497cae
|
@ -287,5 +287,7 @@
|
|||
<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>
|
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(gpu-particles VERSION 0.0.8)
|
||||
project(gpu-particles VERSION 0.0.9)
|
||||
|
||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||
|
|
58
src/main.cpp
58
src/main.cpp
|
@ -34,8 +34,35 @@ 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)
|
||||
{
|
||||
|
@ -47,8 +74,7 @@ public:
|
|||
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
|
||||
{
|
||||
|
@ -57,6 +83,16 @@ public:
|
|||
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)
|
||||
|
@ -68,6 +104,21 @@ private:
|
|||
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:
|
||||
|
@ -81,8 +132,7 @@ public:
|
|||
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
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue