/*
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.
skinsize = texture.sizeX;
GLuint type = GL_RGBA;
- if (texture.bpp == 24)
+ if (texture.bpp == 24) {
type = GL_RGB;
+ }
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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);
void Texture::bind()
{
- if (tex)
+ if (tex) {
tex->bind();
- else
+ } else {
glBindTexture(GL_TEXTURE_2D, 0);
+ }
}