]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Graphic/Texture.cpp
Added braces to all statements with clang-tidy and ran clang-format again
[lugaru.git] / Source / Graphic / Texture.cpp
index 9dd4ea60be08eac20d5fbc66e04125598944c0b9..4b4b9ea7636e50e8811cdb1b114b679f93ca658b 100644 (file)
@@ -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);
@@ -76,16 +79,26 @@ void TextureRes::bind()
     glBindTexture(GL_TEXTURE_2D, id);
 }
 
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap):
-    id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(false),
-    skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap)
+    : id(0)
+    , filename(_filename)
+    , hasMipmap(_hasMipmap)
+    , isSkin(false)
+    , skinsize(0)
+    , data(NULL)
+    , datalen(0)
 {
     load();
 }
 
-TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep):
-    id(0), filename(_filename), hasMipmap(_hasMipmap), isSkin(true),
-    skinsize(0), data(NULL), datalen(0)
+TextureRes::TextureRes(const string& _filename, bool _hasMipmap, GLubyte* array, int* skinsizep)
+    : id(0)
+    , filename(_filename)
+    , hasMipmap(_hasMipmap)
+    , isSkin(true)
+    , skinsize(0)
+    , data(NULL)
+    , datalen(0)
 {
     load();
     *skinsizep = skinsize;
@@ -112,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);
+    }
 }