Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ONE::render::TextureManager Class Reference

Inheritance diagram for ONE::render::TextureManager:

Inheritance graph
[legend]
List of all members.

Detailed Description

manages loading and caching of Texture s

All used textures should be acquired through this class in order to minimize memory usage.
Note that the texture sources passed to the various get functions are not used to identify the textures. Thus, a call to get may return a cached texture that was created through a different method than the one implied by the source parameters.

Author:
Daniel Seibert


Public Member Functions

void clear ()
 clears the cache
Sto get (const Key &k)
 retrieves the object identified by k
TextureRef get (std::string files[6], const G3D::TextureFormat *frm=G3D::TextureFormat::AUTO, Texture::WrapMode wrp=Texture::CLAMP, Texture::InterpolateMode intr=Texture::TRILINEAR_MIPMAP, Texture::DepthReadMode dep=Texture::DEPTH_NORMAL)
 retrieves or creates the cube map with the given attributes
TextureRef get (const std::string &file, const G3D::TextureFormat *, Texture::WrapMode, Texture::InterpolateMode, Texture::Dimension=Texture::DIM_2D, Texture::DepthReadMode=Texture::DEPTH_NORMAL)
 retrieves or creates the texture with the given attributes
TextureRef get (const int &w, const int &h, const std::string &name, const G3D::TextureFormat *, Texture::WrapMode, Texture::InterpolateMode, Texture::Dimension=Texture::DIM_2D, Texture::DepthReadMode=Texture::DEPTH_NORMAL)
 retrieves or creates the texture with the given attributes
TextureRef get (Image *src, const std::string &name, const G3D::TextureFormat *, Texture::WrapMode, Texture::InterpolateMode, Texture::Dimension=Texture::DIM_2D, Texture::DepthReadMode=Texture::DEPTH_NORMAL)
 retrieves or creates the texture with the given attributes
unsigned int getCount () const
bool isCached (const Key &k) const
 checks if the object identified by k is cached
void remove (const Key &k)
 removes an object from the cache
 TextureManager ()
 ~TextureManager ()

Protected Member Functions

virtual Sto create (const Key &)=0
TextureRef create (const TextureInfo &)
virtual void dispose (Sto &)=0
void dispose (TextureRef &)
virtual std::string toString (const Key &) const =0
 converts the given key to an identifier string
std::string toString (const TextureInfo &) const


Constructor & Destructor Documentation

ONE::render::TextureManager::TextureManager  ) 
 

ONE::render::TextureManager::~TextureManager  ) 
 


Member Function Documentation

template<typename T, typename Key, typename Sto>
void ONE::util::ResourceManagerBase< T, Key, Sto >::clear  )  [inherited]
 

clears the cache

All cached resources are destroyed. Note that calling this function will invalidate any pointer to a cached resource that may be held elsewhere.

template<typename T, typename Key, typename Sto>
virtual Sto ONE::util::ResourceManagerBase< T, Key, Sto >::create const Key  )  [protected, pure virtual, inherited]
 

Implemented in ONE::util::ResourceManager< T, Key, Handle< T > >.

TextureRef ONE::render::TextureManager::create const TextureInfo  )  [protected]
 

template<typename T, typename Key, typename Sto>
virtual void ONE::util::ResourceManagerBase< T, Key, Sto >::dispose Sto &   )  [protected, pure virtual, inherited]
 

Implemented in ONE::util::ResourceManager< T, Key, T * >, and ONE::util::ResourceManager< T, Key, Handle< T > >.

void ONE::render::TextureManager::dispose TextureRef  )  [protected]
 

template<typename T, typename Key, typename Sto>
Sto ONE::util::ResourceManagerBase< T, Key, Sto >::get const Key k  )  [inherited]
 

retrieves the object identified by k

If k is found in the cache, the cached object is returned. Otherwise, a new object is created through the create function, cached via insert and returned.

Parameters:
k the key identifying the desired object
Returns:
an object as specified above

TextureRef ONE::render::TextureManager::get std::string  files[6],
const G3D::TextureFormat *  frm = G3D::TextureFormat::AUTO,
Texture::WrapMode  wrp = Texture::CLAMP,
Texture::InterpolateMode  intr = Texture::TRILINEAR_MIPMAP,
Texture::DepthReadMode  dep = Texture::DEPTH_NORMAL
 

retrieves or creates the cube map with the given attributes

If not already cached, the texture is created from the given files.

TextureRef ONE::render::TextureManager::get const std::string &  file,
const G3D::TextureFormat *  ,
Texture::WrapMode  ,
Texture::InterpolateMode  ,
Texture::Dimension  = Texture::DIM_2D,
Texture::DepthReadMode  = Texture::DEPTH_NORMAL
 

retrieves or creates the texture with the given attributes

If not already cached, the texture is created from the given file.

TextureRef ONE::render::TextureManager::get const int &  w,
const int &  h,
const std::string &  name,
const G3D::TextureFormat *  ,
Texture::WrapMode  ,
Texture::InterpolateMode  ,
Texture::Dimension  = Texture::DIM_2D,
Texture::DepthReadMode  = Texture::DEPTH_NORMAL
 

retrieves or creates the texture with the given attributes

If not already cached, an empty texture with the given dimension is created.

TextureRef ONE::render::TextureManager::get Image src,
const std::string &  name,
const G3D::TextureFormat *  ,
Texture::WrapMode  ,
Texture::InterpolateMode  ,
Texture::Dimension  = Texture::DIM_2D,
Texture::DepthReadMode  = Texture::DEPTH_NORMAL
 

retrieves or creates the texture with the given attributes

If not already cached, the texture is created from the given image. Use the ImageManager to prevent multiple loading of images.

template<typename T, typename Key, typename Sto>
unsigned int ONE::util::ResourceManagerBase< T, Key, Sto >::getCount  )  const [inline, inherited]
 

Returns:
the number of cached objects

template<typename T, typename Key, typename Sto>
bool ONE::util::ResourceManagerBase< T, Key, Sto >::isCached const Key k  )  const [inline, inherited]
 

checks if the object identified by k is cached

The resource will not be loaded if k is not found. Note that this function runs in O(log n) time.

Parameters:
k the desired key

template<typename T, typename Key, typename Sto>
void ONE::util::ResourceManagerBase< T, Key, Sto >::remove const Key k  )  [inherited]
 

removes an object from the cache

The removed object is destroyed. Note that this will invalidate any pointer to the resource that may be held elsewhere. If k is unknown, this function will fail silently.

Parameters:
k a key

template<typename T, typename Key, typename Sto>
virtual std::string ONE::util::ResourceManagerBase< T, Key, Sto >::toString const Key  )  const [protected, pure virtual, inherited]
 

converts the given key to an identifier string

The return value is stored in the resource map and must serve as a unique identifier for the key.

std::string ONE::render::TextureManager::toString const TextureInfo  )  const [protected]
 


Generated on Wed Sep 7 19:03:27 2005 for ONEngine by  doxygen 1.4.3