From bbe659ebfa2017bbe4529e1d2f2b3a849805b9df Mon Sep 17 00:00:00 2001 From: ncuxonaT Date: Sun, 30 Nov 2025 16:21:28 +0300 Subject: [PATCH] ref: gl: fix loading texture arrays --- ref/gl/gl_image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ref/gl/gl_image.c b/ref/gl/gl_image.c index 46fbe099..eb6b07c7 100644 --- a/ref/gl/gl_image.c +++ b/ref/gl/gl_image.c @@ -1109,6 +1109,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic ) uint i, j, numSides; uint offset = 0; qboolean normalMap; + qboolean texture3d; const byte *bufend; // dedicated server @@ -1156,6 +1157,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic ) texsize = GL_CalcTextureSize( tex->format, tex->width, tex->height, tex->depth ); normalMap = FBitSet( tex->flags, TF_NORMALMAP ) ? true : false; numSides = FBitSet( pic->flags, IMAGE_CUBEMAP ) ? 6 : 1; + texture3d = ( tex->target == GL_TEXTURE_3D ); // uploading texture into video memory, change the binding glState.currentTextures[glState.activeTMU] = tex->texnum; @@ -1174,7 +1176,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic ) { width = Q_max( 1, ( tex->width >> j )); height = Q_max( 1, ( tex->height >> j )); - depth = Q_max( 1, ( tex->depth >> j )); + depth = texture3d ? Q_max( 1, ( tex->depth >> j )) : tex->depth; texsize = GL_CalcTextureSize( tex->format, width, height, depth ); size = GL_CalcImageSize( pic->type, width, height, depth ); GL_TextureImageCompressed( tex, i, j, width, height, depth, size, buf ); @@ -1191,7 +1193,7 @@ static qboolean GL_UploadTexture( gl_texture_t *tex, rgbdata_t *pic ) { width = Q_max( 1, ( tex->width >> j )); height = Q_max( 1, ( tex->height >> j )); - depth = Q_max( 1, ( tex->depth >> j )); + depth = texture3d ? Q_max( 1, ( tex->depth >> j )) : tex->depth; texsize = GL_CalcTextureSize( tex->format, width, height, depth ); size = GL_CalcImageSize( pic->type, width, height, depth ); GL_TextureImageRAW( tex, i, j, width, height, depth, pic->type, buf );