diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-22 01:01:02 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2024-10-22 01:01:02 +0100 |
commit | 9edf8711471db08427c5441ed37b6dfe3dd7f3b4 (patch) | |
tree | 4356058e9fd85e44c4404c5db8d5d3322a64aa29 /gfx/models/texture.cpp | |
parent | Bump to CTRE to v3.9.0-1-gacb2f4d to fix compilation with clang 19 (diff) | |
parent | Further template maths functions (diff) | |
download | ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.tar.bz2 ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.tar.xz ilt-9edf8711471db08427c5441ed37b6dfe3dd7f3b4.zip |
Merge branch 'billboard-shadows'
Diffstat (limited to 'gfx/models/texture.cpp')
-rw-r--r-- | gfx/models/texture.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/gfx/models/texture.cpp b/gfx/models/texture.cpp index 51223aa..a508421 100644 --- a/gfx/models/texture.cpp +++ b/gfx/models/texture.cpp @@ -59,12 +59,13 @@ Texture::bind(GLenum unit) const glBindTexture(type, m_texture); } -TextureAbsCoord +TextureDimensions Texture::getSize(const glTexture & texture) { - TextureAbsCoord size; + TextureDimensions size {}; glGetTextureLevelParameteriv(texture, 0, GL_TEXTURE_WIDTH, &size.x); glGetTextureLevelParameteriv(texture, 0, GL_TEXTURE_HEIGHT, &size.y); + glGetTextureLevelParameteriv(texture, 0, GL_TEXTURE_DEPTH, &size.z); return size; } @@ -73,7 +74,7 @@ Texture::save( const glTexture & texture, GLenum format, GLenum type, uint8_t channels, const char * path, uint8_t tgaFormat) { const auto size = getSize(texture); - const size_t dataSize = (static_cast<size_t>(size.x * size.y * channels)); + const size_t dataSize = (static_cast<size_t>(size.x * size.y * size.z * channels)); const size_t fileSize = dataSize + sizeof(TGAHead); filesystem::fh out {path, O_RDWR | O_CREAT, 0660}; @@ -81,7 +82,7 @@ Texture::save( auto tga = out.mmap(fileSize, 0, PROT_WRITE, MAP_SHARED); *tga.get<TGAHead>() = { .format = tgaFormat, - .size = size, + .size = {size.x, size.y * size.z}, .pixelDepth = static_cast<uint8_t>(8 * channels), }; glPixelStorei(GL_PACK_ALIGNMENT, 1); |