added NPOT check to rlLoadTexture to match rlGenTextureMipmaps and WebGL 1.0 standard

This commit is contained in:
noinodev 2026-04-29 11:17:49 +10:00
parent 2dd8d7e8b1
commit f907fc40f3

View File

@ -3366,8 +3366,15 @@ unsigned int rlLoadTexture(const void *data, int width, int height, int format,
// Texture parameters configuration
// NOTE: glTexParameteri does NOT affect texture uploading
#if defined(GRAPHICS_API_OPENGL_ES2)
// Check if texture is power-of-two (POT)
bool texIsPOT = false;
if (((width > 0) && ((width & (width - 1)) == 0)) &&
((height > 0) && ((height & (height - 1)) == 0))) texIsPOT = true;
// NOTE: OpenGL ES 2.0 with no GL_OES_texture_npot support (i.e. WebGL) has limited NPOT support, so CLAMP_TO_EDGE must be used
if (RLGL.ExtSupported.texNPOT)
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT))
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); // Set texture to repeat on x-axis
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); // Set texture to repeat on y-axis