]> git.jsancho.org Git - lugaru.git/commitdiff
glDeleteTextures safely ignores zeroes
authorsf17k <sf171k@gmail.com>
Fri, 3 Jun 2011 19:57:10 +0000 (15:57 -0400)
committersf17k <sf171k@gmail.com>
Fri, 3 Jun 2011 19:57:10 +0000 (15:57 -0400)
Source/GameInitDispose.cpp
Source/Models.cpp
Source/Objects.cpp
Source/Skybox.cpp
Source/Sprite.cpp
Source/Terrain.cpp
Source/Text.cpp
Source/Texture.cpp
Source/Weapons.cpp

index ee82765eea5200fcdee808c0b383f57dccbb208a..8c0917914c4bcb3b9b79d544503292b53f0feefc 100644 (file)
@@ -142,17 +142,15 @@ void Game::deleteGame(){
         delete skybox;
     if(text)
         delete text;
-    for(int i=0;i<10;i++){
-        if(Mainmenuitems[i])glDeleteTextures( 1, &Mainmenuitems[i] );
-    }
+    glDeleteTextures( 10, &Mainmenuitems[0] );
     glDeleteTextures( 1, &cursortexture );
     glDeleteTextures( 1, &Maparrowtexture );
     glDeleteTextures( 1, &Mapboxtexture );
     glDeleteTextures( 1, &Mapcircletexture );
     glDeleteTextures( 1, &terraintexture );
     glDeleteTextures( 1, &terraintexture2 );
-    if(screentexture>0)glDeleteTextures( 1, &screentexture );
-    if(screentexture2>0)glDeleteTextures( 1, &screentexture2 );
+    glDeleteTextures( 1, &screentexture );
+    glDeleteTextures( 1, &screentexture2 );
     glDeleteTextures( 1, &hawktexture );
     glDeleteTextures( 1, &logotexture );
     glDeleteTextures( 1, &loadscreentexture );
@@ -754,10 +752,7 @@ void Game::LoadStuff()
 
        for(i=0;i<maxplayers;i++)
        {
-               if (glIsTexture(player[i].skeleton.drawmodel.textureptr))
-               {
-                       glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
-               }
+        glDeleteTextures(1, &player[i].skeleton.drawmodel.textureptr);
                player[i].skeleton.drawmodel.textureptr=0;;
        }
 
index f49ddd02e64daf65fe4086a2e7ef06c3196bbc82..bdc44dcdd2182a76278f95c4641a85ab1006d890 100644 (file)
@@ -1386,7 +1386,7 @@ Model::~Model()
 {
        deallocate();
 
-       if(textureptr) glDeleteTextures( 1, &textureptr );
+       glDeleteTextures( 1, &textureptr );
 }
 
 void Model::deallocate()
index 353fa6e31f74b8d88215b2aa40928466b447bd74..de603c1655d52fe58c341943efd904d81a0da6b6 100644 (file)
@@ -787,9 +787,9 @@ Objects::Objects()
 
 Objects::~Objects()
 {
-       if (boxtextureptr) glDeleteTextures( 1, &boxtextureptr );
-       if (treetextureptr) glDeleteTextures( 1, &treetextureptr );
-       if (bushtextureptr) glDeleteTextures( 1, &bushtextureptr );
-       if (rocktextureptr) glDeleteTextures( 1, &rocktextureptr );
+       glDeleteTextures( 1, &boxtextureptr );
+       glDeleteTextures( 1, &treetextureptr );
+       glDeleteTextures( 1, &bushtextureptr );
+       glDeleteTextures( 1, &rocktextureptr );
 };
 
index 5c4aaab1fb10a8748d2edf769d82cf30560d262f..f42dd4d87534af4ccf50f769e4e6aa8553829d78 100644 (file)
@@ -134,11 +134,11 @@ void      SkyBox::draw()
 
 SkyBox::~SkyBox()
 {
-       if (front) glDeleteTextures( 1, &front );
-       if (left) glDeleteTextures( 1, &left );
-       if (back) glDeleteTextures( 1, &back );
-       if (right) glDeleteTextures( 1, &right );
-       if (up) glDeleteTextures( 1, &up );
-       if (down) glDeleteTextures( 1, &down );
+       glDeleteTextures( 1, &front );
+       glDeleteTextures( 1, &left );
+       glDeleteTextures( 1, &back );
+       glDeleteTextures( 1, &right );
+       glDeleteTextures( 1, &up );
+       glDeleteTextures( 1, &down );
 };
 
index dbc9c230455e7eb6eb87e1d12644db1c3ac9db23..79a5af45a6cf37150524e7f5acd789e03f84f50a 100644 (file)
@@ -438,16 +438,16 @@ Sprite::Sprite()
 
 void Sprite::clearTextures()
 {
-       if (toothtexture) glDeleteTextures( 1, &toothtexture );
-       if (cloudtexture) glDeleteTextures( 1, &cloudtexture );
-       if (cloudimpacttexture) glDeleteTextures( 1, &cloudimpacttexture );
-       if (bloodtexture) glDeleteTextures( 1, &bloodtexture );
-       if (flametexture) glDeleteTextures( 1, &flametexture );
-       if (bloodflametexture) glDeleteTextures( 1, &bloodflametexture );
-       if (smoketexture) glDeleteTextures( 1, &smoketexture );
-       if (snowflaketexture) glDeleteTextures( 1, &snowflaketexture );
-       if (shinetexture) glDeleteTextures( 1, &shinetexture );
-       if (splintertexture) glDeleteTextures( 1, &splintertexture );
-       if (leaftexture) glDeleteTextures( 1, &leaftexture );
+       glDeleteTextures( 1, &toothtexture );
+       glDeleteTextures( 1, &cloudtexture );
+       glDeleteTextures( 1, &cloudimpacttexture );
+       glDeleteTextures( 1, &bloodtexture );
+       glDeleteTextures( 1, &flametexture );
+       glDeleteTextures( 1, &bloodflametexture );
+       glDeleteTextures( 1, &smoketexture );
+       glDeleteTextures( 1, &snowflaketexture );
+       glDeleteTextures( 1, &shinetexture );
+       glDeleteTextures( 1, &splintertexture );
+       glDeleteTextures( 1, &leaftexture );
 }
 
index 74afa40af14551efc81a94686f266a3d58a4409c..acdc3223465261c58b3288f09516173756d13207 100644 (file)
@@ -1563,12 +1563,12 @@ Terrain::Terrain()
 }
 Terrain::~Terrain()
 {
-       if(terraintexture)glDeleteTextures( 1, &terraintexture );
-       if(shadowtexture) glDeleteTextures( 1, &shadowtexture );
-       if(bodyprinttexture) glDeleteTextures( 1, &bodyprinttexture );
-       if(footprinttexture) glDeleteTextures( 1, &footprinttexture );
-       if(bloodtexture) glDeleteTextures( 1, &bloodtexture );
-       if(bloodtexture2) glDeleteTextures( 1, &bloodtexture2 );
-       if(breaktexture) glDeleteTextures( 1, &breaktexture );
+       glDeleteTextures( 1, &terraintexture );
+       glDeleteTextures( 1, &shadowtexture );
+       glDeleteTextures( 1, &bodyprinttexture );
+       glDeleteTextures( 1, &footprinttexture );
+       glDeleteTextures( 1, &bloodtexture );
+       glDeleteTextures( 1, &bloodtexture2 );
+       glDeleteTextures( 1, &breaktexture );
 }
 
index 4c22f0fd973e08b0a85e47298fc0ab1bfa47ea95..11b1c8d083f67a6ef3524d7ef35060a4b1acbdd2 100644 (file)
@@ -193,6 +193,6 @@ Text::~Text()
                glDeleteLists(base, 512);
                base = 0;
        }
-       if (FontTexture) glDeleteTextures( 1, &FontTexture );
+       glDeleteTextures( 1, &FontTexture );
 }
 
index 92c69d5c93c82472c92511c4cfa754884e610efb..a8df84ae9c1b244dd6b70a3c98d6ebc8ab4e62d4 100644 (file)
@@ -11,8 +11,7 @@ extern bool trilinear;
 
 Texture::~Texture()  {
        free(array);
-       if(id)
-               glDeleteTextures(1,&id);
+    glDeleteTextures(1,&id);
 }
 
 void Texture::load()  {
index 2f6a1ffd65106ed999e25df90608104433b89347..4d8f32ec7cddf536780d416e701cdadd3df2986d 100644 (file)
@@ -1073,12 +1073,12 @@ Weapons::Weapons()
 
 Weapons::~Weapons()
 {
-       if (Weapon::stafftextureptr) glDeleteTextures( 1, &Weapon::stafftextureptr );
-       if (Weapon::knifetextureptr) glDeleteTextures( 1, &Weapon::knifetextureptr );
-       if (Weapon::lightbloodknifetextureptr) glDeleteTextures( 1, &Weapon::lightbloodknifetextureptr );
-       if (Weapon::bloodknifetextureptr) glDeleteTextures( 1, &Weapon::bloodknifetextureptr );
-       if (Weapon::swordtextureptr) glDeleteTextures( 1, &Weapon::swordtextureptr );
-       if (Weapon::lightbloodswordtextureptr) glDeleteTextures( 1, &Weapon::lightbloodswordtextureptr );
-       if (Weapon::bloodswordtextureptr) glDeleteTextures( 1, &Weapon::bloodswordtextureptr );
+       glDeleteTextures( 1, &Weapon::stafftextureptr );
+       glDeleteTextures( 1, &Weapon::knifetextureptr );
+       glDeleteTextures( 1, &Weapon::lightbloodknifetextureptr );
+       glDeleteTextures( 1, &Weapon::bloodknifetextureptr );
+       glDeleteTextures( 1, &Weapon::swordtextureptr );
+       glDeleteTextures( 1, &Weapon::lightbloodswordtextureptr );
+       glDeleteTextures( 1, &Weapon::bloodswordtextureptr );
 }