Browse Source

REVIEWED: `rlGenTextureMipmaps()`, GPU generation only

pull/2886/head
Ray 2 years ago
parent
commit
f68bb8c707
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      src/rlgl.h

+ 4
- 2
src/rlgl.h View File

@ -3248,6 +3248,7 @@ void rlUnloadTexture(unsigned int id)
// NOTE: Only supports GPU mipmap generation
void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int *mipmaps)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
glBindTexture(GL_TEXTURE_2D, id);
// Check if texture is power-of-two (POT)
@ -3256,7 +3257,6 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int
if (((width > 0) && ((width & (width - 1)) == 0)) &&
((height > 0) && ((height & (height - 1)) == 0))) texIsPOT = true;
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
if ((texIsPOT) || (RLGL.ExtSupported.texNPOT))
{
//glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE); // Hint for mipmaps generation algorithm: GL_FASTEST, GL_NICEST, GL_DONT_CARE
@ -3268,10 +3268,12 @@ void rlGenTextureMipmaps(unsigned int id, int width, int height, int format, int
*mipmaps = 1 + (int)floor(log(MAX(width, height))/log(2));
TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Mipmaps generated automatically, total: %i", id, *mipmaps);
}
#endif
else TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] Failed to generate mipmaps", id);
glBindTexture(GL_TEXTURE_2D, 0);
#else
TRACELOG(RL_LOG_WARNING, "TEXTURE: [ID %i] GPU mipmap generation not supported", id);
#endif
}

Loading…
Cancel
Save