summaryrefslogtreecommitdiff
path: root/gfx/models/texture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/models/texture.cpp')
-rw-r--r--gfx/models/texture.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index cff44f9..e311937 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -13,7 +13,12 @@ Texture::Texture(const std::filesystem::path & fileName) :
{
}
-Texture::Texture(const Image & tex)
+Texture::Texture(const Image & tex) :
+ Texture {static_cast<GLsizei>(tex.width), static_cast<GLsizei>(tex.height), tex.data.data()}
+{
+}
+
+Texture::Texture(GLsizei width, GLsizei height, void * data)
{
glBindTexture(GL_TEXTURE_2D, m_texture);
@@ -22,8 +27,7 @@ Texture::Texture(const Image & tex)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, static_cast<GLsizei>(tex.width), static_cast<GLsizei>(tex.height), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, tex.data.data());
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
void