From 7c03d93c367b842c464dca30e121bc4c20547c36 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 Jan 2022 16:44:19 +0000 Subject: Generic solution for glGen/glDel arrays, then tidy-up the uses --- gfx/models/mesh.cpp | 3 +-- gfx/models/mesh.h | 3 +-- gfx/models/texture.cpp | 10 +++------- gfx/models/texture.h | 10 ++-------- 4 files changed, 7 insertions(+), 19 deletions(-) (limited to 'gfx/models') diff --git a/gfx/models/mesh.cpp b/gfx/models/mesh.cpp index 09c2872..f13e242 100644 --- a/gfx/models/mesh.cpp +++ b/gfx/models/mesh.cpp @@ -1,6 +1,5 @@ #include "mesh.h" -#include "glBuffers.h" -#include "glVertexArrays.h" +#include "glArrays.h" #include "vertex.hpp" #include diff --git a/gfx/models/mesh.h b/gfx/models/mesh.h index 4e6cec8..9b74f48 100644 --- a/gfx/models/mesh.h +++ b/gfx/models/mesh.h @@ -2,8 +2,7 @@ #define MESH_INCLUDED_H #include -#include -#include +#include #include #include diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index cd275e8..612f0a0 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -1,4 +1,6 @@ #include "texture.h" +#include "glArrays.h" +#include #include #include #include @@ -6,11 +8,10 @@ Cache Texture::cachedTexture; -Texture::Texture(const std::filesystem::path & fileName) : m_texture {} +Texture::Texture(const std::filesystem::path & fileName) { const Image tex {Resource::mapPath(fileName).c_str(), STBI_rgb_alpha}; - glGenTextures(1, &m_texture); glBindTexture(GL_TEXTURE_2D, m_texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); @@ -22,11 +23,6 @@ Texture::Texture(const std::filesystem::path & fileName) : m_texture {} GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data()); } -Texture::~Texture() -{ - glDeleteTextures(1, &m_texture); -} - void Texture::Bind() const { diff --git a/gfx/models/texture.h b/gfx/models/texture.h index 8bbba85..6dbe9af 100644 --- a/gfx/models/texture.h +++ b/gfx/models/texture.h @@ -1,9 +1,8 @@ #ifndef TEXTURE_H #define TEXTURE_H -#include #include -#include +#include template class Cache; @@ -11,17 +10,12 @@ class Texture { public: explicit Texture(const std::filesystem::path & fileName); - virtual ~Texture(); - - NO_COPY(Texture); - NO_MOVE(Texture); - static Cache cachedTexture; void Bind() const; private: - GLuint m_texture; + glTexture m_texture; }; #endif -- cgit v1.2.3