00001 #include "texture.h" 00002 #include "../openglserver/openglserver.h" 00003 00004 using namespace boost; 00005 using namespace kerosin; 00006 00007 Texture::Texture(const boost::shared_ptr<TextureServer> &textureServer) : 00008 mTexID(0), mWidth(0), mHeight(0), mTextureServer(textureServer) 00009 { 00010 } 00011 00012 Texture::~Texture() 00013 { 00014 Reset(); 00015 } 00016 00017 void Texture::Reset() 00018 { 00019 if (mTexID) 00020 { 00021 glDeleteTextures(1, &mTexID); 00022 mTexID = 0; 00023 } 00024 } 00025 00026 void Texture::Acquire() 00027 { 00028 Reset(); 00029 glGenTextures(1, &mTexID); 00030 } 00031 00032 unsigned int Texture::GetWidth() const 00033 { 00034 return mWidth; 00035 } 00036 00037 unsigned int Texture::GetHeight() const 00038 { 00039 return mHeight; 00040 } 00041 00042 boost::shared_ptr<TextureServer> Texture::GetTextureServer() const 00043 { 00044 return make_shared(mTextureServer); 00045 }