X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGraphic%2FTexture.cpp;h=94e4e09c3185bcd2ea01e6c3120e6f2679fc1217;hb=0aab437dc560d2afa982e61cc2547756ad7b0761;hp=69ff28ed5931727020b143305554da462f5bd0c7;hpb=8b6e8f3ad7390309795eb35c0959264cb7924402;p=lugaru.git diff --git a/Source/Graphic/Texture.cpp b/Source/Graphic/Texture.cpp index 69ff28e..94e4e09 100644 --- a/Source/Graphic/Texture.cpp +++ b/Source/Graphic/Texture.cpp @@ -1,6 +1,6 @@ /* Copyright (C) 2003, 2010 - Wolfire Games -Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file) +Copyright (C) 2010-2017 - Lugaru contributors (see AUTHORS file) This file is part of Lugaru. @@ -39,8 +39,9 @@ void TextureRes::load() skinsize = texture.sizeX; GLuint type = GL_RGBA; - if (texture.bpp == 24) + if (texture.bpp == 24) { type = GL_RGB; + } glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -62,9 +63,11 @@ void TextureRes::load() const int nb = texture.sizeY * texture.sizeX * (texture.bpp / 8); data = (GLubyte*)malloc(nb * sizeof(GLubyte)); datalen = 0; - for (int i = 0; i < nb; i++) - if ((i + 1) % 4 || type == GL_RGB) + for (int i = 0; i < nb; i++) { + if ((i + 1) % 4 || type == GL_RGB) { data[datalen++] = texture.data[i]; + } + } glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, data); } else { glTexImage2D(GL_TEXTURE_2D, 0, type, texture.sizeX, texture.sizeY, 0, type, GL_UNSIGNED_BYTE, texture.data); @@ -122,8 +125,9 @@ void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* void Texture::bind() { - if (tex) + if (tex) { tex->bind(); - else + } else { glBindTexture(GL_TEXTURE_2D, 0); + } }