File: example0001.cc - Tab length: 1 2 4 8 - Lines: on off - No wrap: on offclass Texture
{
public:
Texture (const char* path)
{
this->refCount = malloc (sizeof (*this->refCount)); // compteur partag� du nombre de r�f�rences sur cette textures
*this->refCount = 1;
this->imageData = new char [...];
// charger l'image "path" dans this->image_data
}
Texture (const Texture& texture)
{
this->refCount = texture.refCount; // on r�cup�re le compteur partag� pour compter une nouvelle r�f�rence
++*this->refCount;
this->imageData = texture.imageData;
}
~Texture ()
{
if (--*this->refCount == 0) // si le compteur arrive � 0, alors plus aucun objet ne r�f�rence cette texture,
{
delete [] this->imageData; // on peut donc l'effacer pour de bon
free (this->refCount); // sans oublier de supprimer �galement le compteur
}
}
private:
char* imageData;
int* refCount;
}