diff --git a/src/nostalgia/core/userland/gfx_opengl.cpp b/src/nostalgia/core/userland/gfx_opengl.cpp index 17081139..ae3eee96 100644 --- a/src/nostalgia/core/userland/gfx_opengl.cpp +++ b/src/nostalgia/core/userland/gfx_opengl.cpp @@ -118,11 +118,11 @@ static void initBackgroundBufferObjects(Context *ctx, Background *bg) noexcept { static void initBackgroundBufferset(Context *ctx, GLuint shader, Background *bg) { // vao - glGenVertexArrays(1, &bg->vao); + glGenVertexArrays(1, &bg->vao.id); glBindVertexArray(bg->vao); // vbo & ebo - glGenBuffers(1, &bg->vbo); - glGenBuffers(1, &bg->ebo); + glGenBuffers(1, &bg->vbo.id); + glGenBuffers(1, &bg->ebo.id); initBackgroundBufferObjects(ctx, bg); sendVbo(*bg); sendEbo(*bg); @@ -200,9 +200,6 @@ ox::Error init(Context *ctx) { ox::Error shutdown(Context *ctx) { const auto id = ctx->rendererData(); - for (auto &bg : id->backgrounds) { - destroy(bg); - } ctx->setRendererData(nullptr); delete id; return OxError(0); diff --git a/src/nostalgia/core/userland/glutils.cpp b/src/nostalgia/core/userland/glutils.cpp index 04b51c4e..3c3b8ba7 100644 --- a/src/nostalgia/core/userland/glutils.cpp +++ b/src/nostalgia/core/userland/glutils.cpp @@ -15,13 +15,23 @@ namespace nostalgia::core::renderer { -void deleteTexture(GLuint t) { +void deleteBuffer(GLuint b) noexcept { + glDeleteBuffers(1, &b); +} + +void deleteTexture(GLuint t) noexcept { glDeleteTextures(1, &t); } +void deleteVertexArray(GLuint v) noexcept { + glDeleteVertexArrays(1, &v); +} + +template struct GLobject; +template struct GLobject; +template struct GLobject; template struct GLobject; template struct GLobject; -template struct GLobject; [[nodiscard]] static ox::Result buildShader(GLuint shaderType, const GLchar *src, const char *shaderName) { @@ -50,10 +60,4 @@ ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag) { return ox::move(prgm); } -void destroy(const Bufferset &bufferset) { - glDeleteVertexArrays(1, &bufferset.vao); - glDeleteBuffers(1, &bufferset.ebo); - glDeleteBuffers(1, &bufferset.vbo); -} - } diff --git a/src/nostalgia/core/userland/glutils.hpp b/src/nostalgia/core/userland/glutils.hpp index f23f22b6..ca2c0352 100644 --- a/src/nostalgia/core/userland/glutils.hpp +++ b/src/nostalgia/core/userland/glutils.hpp @@ -90,19 +90,26 @@ struct GLobject: public Base { }; -void deleteTexture(GLuint t); +void deleteBuffer(GLuint b) noexcept; +void deleteTexture(GLuint t) noexcept; +void deleteVertexArray(GLuint v) noexcept; +extern template struct GLobject; +extern template struct GLobject; +extern template struct GLobject; extern template struct GLobject; extern template struct GLobject; -extern template struct GLobject; + +using Buffer = GLobject; using Shader = GLobject; using Program = GLobject; using Texture = GLobject; +using VertexArray = GLobject; struct Bufferset { - GLuint vao = 0; - GLuint vbo = 0; - GLuint ebo = 0; + VertexArray vao; + Buffer vbo; + Buffer ebo; Texture tex; GLsizei eboElements = 0; }; @@ -110,6 +117,4 @@ struct Bufferset { [[nodiscard]] ox::Result buildShaderProgram(const GLchar *vert, const GLchar *frag); -void destroy(const Bufferset &bufferset); - }