From 22e648bb1a5e8fe6e427efc906194edbb9ce6ed8 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 31 Mar 2013 10:03:05 +0200 Subject: [PATCH] png texture: set clamp mode if no mipmaps requested, and don't actually generate mips... --- gfx/texture.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/texture.cpp b/gfx/texture.cpp index ac60e55a66..c214dbaef5 100644 --- a/gfx/texture.cpp +++ b/gfx/texture.cpp @@ -150,12 +150,14 @@ bool Texture::LoadPNG(const uint8_t *data, size_t size, bool genMips) { return false; } GL_CHECK(); + // TODO: should check for power of 2 tex size and disallow genMips when not. glGenTextures(1, &id_); glBindTexture(GL_TEXTURE_2D, id_); - SetTextureParameters(genMips ? ZIM_GEN_MIPS : 0); + SetTextureParameters(genMips ? ZIM_GEN_MIPS : ZIM_CLAMP); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); - glGenerateMipmap(GL_TEXTURE_2D); + if (genMips) + glGenerateMipmap(GL_TEXTURE_2D); GL_CHECK(); free(image_data); return true;