glDepthMask(1);
glPopMatrix();
}
-
-SkyBox::~SkyBox()
-{
- front.destroy();
- left.destroy();
- back.destroy();
- right.destroy();
- up.destroy();
- down.destroy();
-}
void draw();
SkyBox() {}
- ~SkyBox();
};
#endif
memset(decalposition, 0, sizeof(decalposition));
numdecals = 0;
}
-Terrain::~Terrain()
-{
- terraintexture.destroy();
- shadowtexture.destroy();
- bodyprinttexture.destroy();
- footprinttexture.destroy();
- bloodtexture.destroy();
- bloodtexture2.destroy();
- breaktexture.destroy();
-}
-
void DoShadows();
Terrain();
- ~Terrain();
};
#endif
delete skybox;
if (text)
delete text;
- terraintexture.destroy();
- terraintexture2.destroy();
- cursortexture.destroy();
- Maparrowtexture.destroy();
- Mapboxtexture.destroy();
- Mapcircletexture.destroy();
- hawktexture.destroy();
- loadscreentexture.destroy();
-
- for (int i = 0; i < 10; i++)
- Mainmenuitems[i].destroy();
glDeleteTextures(1, &screentexture);
glDeleteTextures(1, &screentexture2);
stillloading = 1;
- for (auto p:Person::players) {
- p->skeleton.drawmodel.textureptr.destroy();
- }
-
visibleloading = 0; //don't use loadscreentexture yet
loadscreentexture.load("Textures/Fire.jpg", 1);
visibleloading = 1;
Model::~Model()
{
deallocate();
- textureptr.destroy();
}
void Model::deallocate()
speed = 0;
rotatespeed = 0;
}
-
-void Sprite::clearTextures()
-{
- toothtexture.destroy();
- cloudtexture.destroy();
- cloudimpacttexture.destroy();
- bloodtexture.destroy();
- flametexture.destroy();
- bloodflametexture.destroy();
- smoketexture.destroy();
- snowflaketexture.destroy();
- shinetexture.destroy();
- splintertexture.destroy();
- leaftexture.destroy();
-}
-
static void setLastSpriteAlivetime(float al) {
sprites.back()->alivetime = al;
}
- static void clearTextures();
static Texture cloudtexture;
static Texture bloodtexture;
glDeleteLists(base, 512);
base = 0;
}
- FontTexture.destroy();
}
{
load();
*skinsizep = skinsize;
- for (int i = 0; i < datalen; i++)
+ for (int i = 0; i < datalen; i++) {
array[i] = data[i];
+ }
}
TextureRes::~TextureRes()
void Texture::load(const string& filename, bool hasMipmap)
{
- destroy();
- tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap);
+ tex.reset(new TextureRes(Folders::getResourcePath(filename), hasMipmap));
}
void Texture::load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep)
{
- destroy();
- tex = new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep);
-}
-
-void Texture::destroy()
-{
- if (tex) {
- delete tex;
- tex = NULL;
- }
+ tex.reset(new TextureRes(Folders::getResourcePath(filename), hasMipmap, array, skinsizep));
}
void Texture::bind()
#include <map>
#include <string>
#include <vector>
-
-using namespace std;
+#include <memory>
class TextureRes
{
TextureRes(const string& filename, bool hasMipmap, GLubyte* array, int* skinsize);
~TextureRes();
void bind();
+
+ /* Make sure TextureRes never gets copied */
+ TextureRes(TextureRes const& other) = delete;
+ TextureRes & operator=(TextureRes const& other) = delete;
};
class Texture
{
private:
- TextureRes* tex;
+ std::shared_ptr<TextureRes> tex;
public:
- inline Texture(): tex(NULL) {}
+ inline Texture(): tex(nullptr) {}
void load(const string& filename, bool hasMipmap);
void load(const string& filename, bool hasMipmap, GLubyte* array, int* skinsizep);
- void destroy();
void bind();
};
Weapons::Weapons()
{
}
-
-Weapons::~Weapons()
-{
- Weapon::stafftextureptr.destroy();
- Weapon::knifetextureptr.destroy();
- Weapon::lightbloodknifetextureptr.destroy();
- Weapon::bloodknifetextureptr.destroy();
- Weapon::swordtextureptr.destroy();
- Weapon::lightbloodswordtextureptr.destroy();
- Weapon::bloodswordtextureptr.destroy();
-}
-
{
public:
Weapons();
- ~Weapons();
int Draw();
void DoStuff();