summaryrefslogtreecommitdiffhomepage
path: root/src/rlgl.h
diff options
context:
space:
mode:
authorRay <[email protected]>2023-09-18 19:43:10 +0200
committerRay <[email protected]>2023-09-18 19:43:10 +0200
commitb3359276654c410033c8d194c0188d2257029f1d (patch)
tree39d02d16f0458ec7eaa8c51bca2867b07029549e /src/rlgl.h
parenteb461512a7191896acda33330e643b0dd60365b3 (diff)
downloadraylib-b3359276654c410033c8d194c0188d2257029f1d.tar.gz
raylib-b3359276654c410033c8d194c0188d2257029f1d.zip
Reviewed PR #3321
Diffstat (limited to 'src/rlgl.h')
-rw-r--r--src/rlgl.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index bef4fdc2..fe69afd6 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -2997,7 +2997,10 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
int mipWidth = width;
int mipHeight = height;
- int mipOffset = 0; // Mipmap data offset
+ int mipOffset = 0; // Mipmap data offset, only used for tracelog
+
+ // NOTE: Added pointer math separately from function to avoid UBSAN complaining
+ unsigned char *dataPtr = (unsigned char *)data;
// Load the different mipmap levels
for (int i = 0; i < mipmapCount; i++)
@@ -3009,10 +3012,6 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
TRACELOGD("TEXTURE: Load mipmap level %i (%i x %i), size: %i, offset: %i", i, mipWidth, mipHeight, mipSize, mipOffset);
- // NOTE: Added pointer math separately from function to avoid UBSAN complaining
- unsigned char *dataPtr = (unsigned char*)data;
- if (mipOffset > 0) dataPtr = (unsigned char*)data + mipOffset;
-
if (glInternalFormat != -1)
{
if (format < RL_PIXELFORMAT_COMPRESSED_DXT1_RGB) glTexImage2D(GL_TEXTURE_2D, i, glInternalFormat, mipWidth, mipHeight, 0, glFormat, glType, dataPtr);
@@ -3040,7 +3039,8 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
mipWidth /= 2;
mipHeight /= 2;
- mipOffset += mipSize;
+ mipOffset += mipSize; // Increment offset position to next mipmap
+ dataPtr += mipSize; // Increment data pointer to next mipmap
// Security check for NPOT textures
if (mipWidth < 1) mipWidth = 1;