diff --git a/src/modules/graphics/Texture.cpp b/src/modules/graphics/Texture.cpp index 477eb33cb..27d491dd1 100644 --- a/src/modules/graphics/Texture.cpp +++ b/src/modules/graphics/Texture.cpp @@ -121,6 +121,7 @@ StringMap::Entry Texture::wrapModeEnt { { "clamp", Texture::WRAP_CLAMP }, { "repeat", Texture::WRAP_REPEAT }, + { "mirroredrepeat", Texture::WRAP_MIRRORED_REPEAT }, }; StringMap Texture::wrapModes(Texture::wrapModeEntries, sizeof(Texture::wrapModeEntries)); diff --git a/src/modules/graphics/Texture.h b/src/modules/graphics/Texture.h index 7b5a525a4..a8e9f16bb 100644 --- a/src/modules/graphics/Texture.h +++ b/src/modules/graphics/Texture.h @@ -44,6 +44,7 @@ public: { WRAP_CLAMP, WRAP_REPEAT, + WRAP_MIRRORED_REPEAT, WRAP_MAX_ENUM }; diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index 86dc51204..0401a9281 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -581,32 +581,22 @@ float OpenGL::setTextureFilter(graphics::Texture::Filter &f) void OpenGL::setTextureWrap(const graphics::Texture::Wrap &w) { - GLint gs, gt; - - switch (w.s) + auto glWrapMode = [](Texture::WrapMode wmode) -> GLint { - case Texture::WRAP_CLAMP: - gs = GL_CLAMP_TO_EDGE; - break; - case Texture::WRAP_REPEAT: - default: - gs = GL_REPEAT; - break; - } + switch (wmode) + { + case Texture::WRAP_CLAMP: + default: + return GL_CLAMP_TO_EDGE; + case Texture::WRAP_REPEAT: + return GL_REPEAT; + case Texture::WRAP_MIRRORED_REPEAT: + return GL_MIRRORED_REPEAT; + } + }; - switch (w.t) - { - case Texture::WRAP_CLAMP: - gt = GL_CLAMP_TO_EDGE; - break; - case Texture::WRAP_REPEAT: - default: - gt = GL_REPEAT; - break; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, gs); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, gt); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapMode(w.s)); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapMode(w.t)); } int OpenGL::getMaxTextureSize() const