diff --git a/src/rlgl.h b/src/rlgl.h index 5c6e95afb..539f409df 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -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