summaryrefslogtreecommitdiff
path: root/gfx/models/texture.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-12-11 12:41:54 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2022-12-11 12:41:54 +0000
commit165b8fa65efb15b2929278687720ca53683e6616 (patch)
tree83a9fa1fe0237542697ca32a4d9a5cfe7a3971ca /gfx/models/texture.cpp
parentAdd a mini C filesystem wrapper library with mmap support (diff)
downloadilt-165b8fa65efb15b2929278687720ca53683e6616.tar.bz2
ilt-165b8fa65efb15b2929278687720ca53683e6616.tar.xz
ilt-165b8fa65efb15b2929278687720ca53683e6616.zip
Support saving textures with different output types
Diffstat (limited to 'gfx/models/texture.cpp')
-rw-r--r--gfx/models/texture.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp
index 6019bec..4718708 100644
--- a/gfx/models/texture.cpp
+++ b/gfx/models/texture.cpp
@@ -43,7 +43,7 @@ Texture::bind(GLenum unit) const
}
void
-Texture::save(const glTexture & texture, GLenum format, const glm::ivec2 & size, unsigned short channels,
+Texture::save(const glTexture & texture, GLenum format, GLenum type, const glm::ivec2 & size, unsigned short channels,
const char * path, short tgaFormat)
{
using TGAHead = std::array<short, 9>;
@@ -56,18 +56,18 @@ Texture::save(const glTexture & texture, GLenum format, const glm::ivec2 & size,
auto tga = out.mmap(fileSize, 0, PROT_WRITE, MAP_SHARED);
*tga.get<TGAHead>() = {0, tgaFormat, 0, 0, 0, 0, static_cast<short>(size.x), static_cast<short>(size.y),
static_cast<short>(8 * channels)};
- glGetTextureImage(texture, 0, format, GL_UNSIGNED_BYTE, static_cast<GLsizei>(dataSize), tga.get<TGAHead>() + 1);
+ glGetTextureImage(texture, 0, format, type, static_cast<GLsizei>(dataSize), tga.get<TGAHead>() + 1);
tga.msync(MS_ASYNC);
}
void
Texture::save(const glTexture & texture, const glm::ivec2 & size, const char * path)
{
- save(texture, GL_BGR, size, 3, path, 2);
+ save(texture, GL_BGR, GL_UNSIGNED_BYTE, size, 3, path, 2);
}
void
Texture::saveDepth(const glTexture & texture, const glm::ivec2 & size, const char * path)
{
- save(texture, GL_DEPTH_COMPONENT, size, 1, path, 3);
+ save(texture, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, size, 1, path, 3);
}