summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-01-01 16:44:19 +0000
commit7c03d93c367b842c464dca30e121bc4c20547c36 (patch)
tree6df340dc3b0bd16f6ced2a051a68fc8a3c67a08c /gfx
parentFirst iteration with font/text support (diff)
downloadilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.bz2
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.tar.xz
ilt-7c03d93c367b842c464dca30e121bc4c20547c36.zip
Generic solution for glGen/glDel arrays, then tidy-up the uses
Diffstat (limited to 'gfx')
-rw-r--r--gfx/models/mesh.cpp3
-rw-r--r--gfx/models/mesh.h3
-rw-r--r--gfx/models/texture.cpp10
-rw-r--r--gfx/models/texture.h10
4 files changed, 7 insertions, 19 deletions
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 <cstddef>
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 <GL/glew.h>
-#include <glBuffers.h>
-#include <glVertexArrays.h>
+#include <glArrays.h>
#include <memory>
#include <span>
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 <GL/glew.h>
#include <cache.h>
#include <gfx/image.h>
#include <resource.h>
@@ -6,11 +8,10 @@
Cache<Texture> 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 <GL/glew.h>
#include <filesystem>
-#include <special_members.hpp>
+#include <glArrays.h>
template<typename Obj> 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<Texture> cachedTexture;
void Bind() const;
private:
- GLuint m_texture;
+ glTexture m_texture;
};
#endif