summaryrefslogtreecommitdiff
path: root/gfx/models/texture.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 16:34:56 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 16:34:56 +0100
commitb4ede2fd89d0effb44ebae15862427de9a147476 (patch)
tree715ed03af8c466b490d4f83183d31a5d57352245 /gfx/models/texture.cpp
parentCreate texture fragments from materials (diff)
downloadilt-b4ede2fd89d0effb44ebae15862427de9a147476.tar.bz2
ilt-b4ede2fd89d0effb44ebae15862427de9a147476.tar.xz
ilt-b4ede2fd89d0effb44ebae15862427de9a147476.zip
Define our own enum for texture mapmode
Diffstat (limited to 'gfx/models/texture.cpp')
-rw-r--r--gfx/models/texture.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index 6319eb8..e29fd6c 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -13,6 +13,21 @@
Cache<Texture, std::filesystem::path> Texture::cachedTexture;
+GLint
+TextureOptions::glMapMode(TextureOptions::MapMode mm)
+{
+ switch (mm) {
+ case MapMode::Repeat:
+ return GL_REPEAT;
+ case MapMode::Clamp:
+ return GL_CLAMP_TO_EDGE;
+ case MapMode::Mirror:
+ return GL_MIRRORED_REPEAT;
+ default:
+ throw std::domain_error("Invalid MapMode value");
+ }
+}
+
Texture::Texture(const std::filesystem::path & fileName, TextureOptions to) :
Texture {Image {Resource::mapPath(fileName).c_str(), STBI_rgb_alpha}, to}
{
@@ -30,8 +45,8 @@ Texture::Texture(GLsizei width, GLsizei height, const void * data, TextureOption
glBindTexture(type, m_texture);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexParameteri(type, GL_TEXTURE_WRAP_S, to.wrap);
- glTexParameteri(type, GL_TEXTURE_WRAP_T, to.wrap);
+ glTexParameteri(type, GL_TEXTURE_WRAP_S, TextureOptions::glMapMode(to.wrapU));
+ glTexParameteri(type, GL_TEXTURE_WRAP_T, TextureOptions::glMapMode(to.wrapV));
glTexParameteri(type, GL_TEXTURE_MIN_FILTER, to.minFilter);
glTexParameteri(type, GL_TEXTURE_MAG_FILTER, to.magFilter);