I have the following class that basically just holds a texture handle, and manages the memory of the texture.
I also have two other classes that are capable of holding data. One is a template class for internal stuff (user can't modify), and one that contains std::maps that I hope will allow me to implement my script system more easily.Code:#ifndef XTEXTURE_H
#define XTEXTURE_H
#include <hge.h>
namespace Varia
{
class Texture
{
public:
Texture():mTexture(0)
{
mHge = hgeCreate(HGE_VERSION);
};
~Texture()
{
if ( mTexture != 0 )
mHge->Texture_Free(mTexture);
//Release the HGE pointer
mHge->Release();
};
//This will not allow you to overwrite the existing texture
HTEXTURE CreateTexture(const char* filename, bool mipmap)
{
if ( mHge != NULL )
{
if (mTexture!=NULL)
return (mTexture);
mTexture = mHge->Texture_Load(filename,0,mipmap);
return (mTexture);
}
return 0;
};
HTEXTURE DeleteTexture()
{
if ( mHge != NULL )
{
mHge->Texture_Free(mTexture);
(mTexture=0);
}
};
HTEXTURE GetTexture()
{
return (mTexture);
};
private:
HGE* mHge;
HTEXTURE mTexture;
};
};
#endif//XTEXTURE_H
Really it is just a question of speed in indirection. Also if indirection is worth all the extra code required.
basicly I have either
I want to use std::map, but I hear that it is substantially slower than std::vector(although with map you don't have to manage the indexes).Code:std::map<size_t, Varia::Texture> mTextures;
//Or
std::map<size_t, Varia::Texture*> mTextures;
Thank you greatly for any assistance.