summaryrefslogtreecommitdiff
path: root/gfx/models/texture.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-29 18:50:02 +0100
commit4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17 (patch)
tree6f4bd0c999e3b4a11410aed234622e80842261ad /gfx/models/texture.h
parentLookup material details once in the vertex shader (diff)
downloadilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.bz2
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.tar.xz
ilt-4fb3a5ae0f53a6fa3f4901f92e64f1de8d2dbb17.zip
Dunno how, but some DOS new lines got in here!
Diffstat (limited to 'gfx/models/texture.h')
-rw-r--r--gfx/models/texture.h122
1 files changed, 61 insertions, 61 deletions
diff --git a/gfx/models/texture.h b/gfx/models/texture.h
index 86e76a0..1b66c64 100644
--- a/gfx/models/texture.h
+++ b/gfx/models/texture.h
@@ -1,61 +1,61 @@
-#pragma once
-
-#include <cache.h>
-#include <filesystem>
-#include <glArrays.h>
-#include <glm/fwd.hpp>
-
-// IWYU pragma: no_forward_declare Cache
-class Image;
-
-struct TextureOptions {
- enum class MapMode {
- Repeat,
- Clamp,
- Mirror,
- Decal,
- };
- MapMode wrapU {MapMode::Repeat}, wrapV {MapMode::Repeat};
- GLint minFilter {GL_LINEAR}, magFilter {GL_LINEAR};
- GLenum type {GL_TEXTURE_2D};
- static GLint glMapMode(MapMode);
-};
-
-class Texture {
-public:
- virtual ~Texture() = default;
- DEFAULT_MOVE_NO_COPY(Texture);
-
- explicit Texture(const std::filesystem::path & fileName, TextureOptions = {});
- explicit Texture(const Image & image, TextureOptions = {});
- explicit Texture(GLsizei width, GLsizei height, TextureOptions = {});
- explicit Texture(GLsizei width, GLsizei height, const void * data, TextureOptions = {});
-
- static Cache<Texture, std::filesystem::path> cachedTexture;
-
- virtual void bind(GLenum unit = GL_TEXTURE0) const;
-
- void save(const char * path) const;
- static void save(const glTexture &, const char * path);
- static void saveDepth(const glTexture &, const char * path);
- static void saveNormal(const glTexture &, const char * path);
-
-protected:
- static void save(const glTexture &, GLenum, GLenum, uint8_t channels, const char * path, uint8_t tgaFormat);
- static glm::ivec2 getSize(const glTexture &);
-
- glTexture m_texture;
- GLenum type;
-};
-
-class TextureAtlas : public Texture {
-public:
- TextureAtlas(GLsizei width, GLsizei height, GLuint count);
-
- void bind(GLenum unit = GL_TEXTURE0) const override;
- GLuint add(glm::ivec2 position, glm::ivec2 size, void * data, TextureOptions = {});
-
-private:
- glTexture m_atlas;
- GLuint used {};
-};
+#pragma once
+
+#include <cache.h>
+#include <filesystem>
+#include <glArrays.h>
+#include <glm/fwd.hpp>
+
+// IWYU pragma: no_forward_declare Cache
+class Image;
+
+struct TextureOptions {
+ enum class MapMode {
+ Repeat,
+ Clamp,
+ Mirror,
+ Decal,
+ };
+ MapMode wrapU {MapMode::Repeat}, wrapV {MapMode::Repeat};
+ GLint minFilter {GL_LINEAR}, magFilter {GL_LINEAR};
+ GLenum type {GL_TEXTURE_2D};
+ static GLint glMapMode(MapMode);
+};
+
+class Texture {
+public:
+ virtual ~Texture() = default;
+ DEFAULT_MOVE_NO_COPY(Texture);
+
+ explicit Texture(const std::filesystem::path & fileName, TextureOptions = {});
+ explicit Texture(const Image & image, TextureOptions = {});
+ explicit Texture(GLsizei width, GLsizei height, TextureOptions = {});
+ explicit Texture(GLsizei width, GLsizei height, const void * data, TextureOptions = {});
+
+ static Cache<Texture, std::filesystem::path> cachedTexture;
+
+ virtual void bind(GLenum unit = GL_TEXTURE0) const;
+
+ void save(const char * path) const;
+ static void save(const glTexture &, const char * path);
+ static void saveDepth(const glTexture &, const char * path);
+ static void saveNormal(const glTexture &, const char * path);
+
+protected:
+ static void save(const glTexture &, GLenum, GLenum, uint8_t channels, const char * path, uint8_t tgaFormat);
+ static glm::ivec2 getSize(const glTexture &);
+
+ glTexture m_texture;
+ GLenum type;
+};
+
+class TextureAtlas : public Texture {
+public:
+ TextureAtlas(GLsizei width, GLsizei height, GLuint count);
+
+ void bind(GLenum unit = GL_TEXTURE0) const override;
+ GLuint add(glm::ivec2 position, glm::ivec2 size, void * data, TextureOptions = {});
+
+private:
+ glTexture m_atlas;
+ GLuint used {};
+};