Reviewed PR #3321
This commit is contained in:
parent
eb461512a7
commit
b335927665
12
src/rlgl.h
12
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user