NL3D::CHLSTextureManager Class Reference

#include <hls_texture_manager.h>


Detailed Description

This is a list of banks of colorisable textures.
Author:
Lionel Berenguier

Nevrax France

Date:
2002

Definition at line 45 of file hls_texture_manager.h.

Public Member Functions

void addBank (CHLSTextureBank *bank)
 Add a compiled bank. Ptr is owned and deleted by the manager.

bool buildTexture (sint textId, NLMISC::CBitmap &out) const
 CHLSTextureManager ()
 Constructor.

sint findTexture (const std::string &name) const
uint getNumTextures () const
 Texture name access.

const char * getTextureName (uint i) const
void reset ()
 ~CHLSTextureManager ()

Private Attributes

std::vector< CHLSTextureBank * > _Banks
std::vector< CHLSTextureBank::CTextureInstanceHandle_Instances


Constructor & Destructor Documentation

NL3D::CHLSTextureManager::CHLSTextureManager  ) 
 

Constructor.

Definition at line 38 of file hls_texture_manager.cpp.

00039 {
00040 }

NL3D::CHLSTextureManager::~CHLSTextureManager  ) 
 

Definition at line 43 of file hls_texture_manager.cpp.

References reset().

00044 {
00045         reset();
00046 }


Member Function Documentation

void NL3D::CHLSTextureManager::addBank CHLSTextureBank bank  ) 
 

Add a compiled bank. Ptr is owned and deleted by the manager.

Definition at line 63 of file hls_texture_manager.cpp.

References _Banks, _Instances, and NL3D::CHLSTextureBank::fillHandleArray().

Referenced by NL3D::CDriverUser::loadHLSBank().

00064 {
00065         // add the bank to the list
00066         _Banks.push_back(bank);
00067 
00068         // Add the bank instance list to the main.
00069         bank->fillHandleArray(_Instances);
00070 
00071         // then re-sort this array.
00072         sort(_Instances.begin(), _Instances.end());
00073 }

bool NL3D::CHLSTextureManager::buildTexture sint  textId,
NLMISC::CBitmap out
const
 

build the colored version bitmap of a texture

Parameters:
textId a texture id returned by findTexture()
Returns:
false if not found

Definition at line 101 of file hls_texture_manager.cpp.

References _Instances, NL3D::CHLSTextureBank::CTextureInstance::buildColorVersion(), and sint.

Referenced by NL3D::CAsyncTextureManager::getNextTextureToUpLoad().

00102 {
00103         if(textId<0 || textId>=(sint)_Instances.size())
00104                 return false;
00105         else
00106         {
00107                 // Ok. build the bitmap
00108                 CHLSTextureBank::CTextureInstance               &textInst= *_Instances[textId].Texture;
00109                 textInst.buildColorVersion(out);
00110                 return true;
00111         }
00112 }

sint NL3D::CHLSTextureManager::findTexture const std::string &  name  )  const
 

search a texture name in the banks (case insensitive), and return its id.

Parameters:
name a texture file name. NB: name is case-lowered first. (case-insensitive)
Returns:
-1 if not found, else return the id.

Definition at line 77 of file hls_texture_manager.cpp.

References _Instances, NL3D::CHLSTextureBank::CTextureInstance::buildAsKey(), NL3D::CHLSTextureBank::CTextureInstance::sameName(), NLMISC::searchLowerBound(), sint, NLMISC::strlwr(), NL3D::CHLSTextureBank::CTextureInstanceHandle::Texture, and uint.

Referenced by NL3D::CAsyncTextureManager::addTextureRef().

00078 {
00079         // empty?
00080         if(_Instances.empty())
00081                 return -1;
00082 
00083         // Build a valid key.
00084         string  nameLwr= strlwr(name);
00085         CHLSTextureBank::CTextureInstance               textKey;
00086         CHLSTextureBank::CTextureInstanceHandle textKeyHandle;
00087         textKey.buildAsKey(nameLwr.c_str());
00088         textKeyHandle.Texture= &textKey;
00089 
00090         // logN search it in the array
00091         uint    id= searchLowerBound(_Instances, textKeyHandle);
00092         // verify if really same name (index must exist since 0 if error, and not empty here)
00093         CHLSTextureBank::CTextureInstance               &textInst= *_Instances[id].Texture;
00094         if( textInst.sameName(nameLwr.c_str()) )
00095                 return id;
00096         else
00097                 return -1;
00098 }

uint NL3D::CHLSTextureManager::getNumTextures  )  const [inline]
 

Texture name access.

Definition at line 71 of file hls_texture_manager.h.

References _Instances, and uint.

00071 {return _Instances.size();}

const char * NL3D::CHLSTextureManager::getTextureName uint  i  )  const
 

Definition at line 116 of file hls_texture_manager.cpp.

References _Instances, nlassert, and uint.

00117 {
00118         nlassert(i<_Instances.size());
00119         return _Instances[i].Texture->getName();
00120 }

void NL3D::CHLSTextureManager::reset  ) 
 

Definition at line 49 of file hls_texture_manager.cpp.

References _Banks, _Instances, and uint.

Referenced by ~CHLSTextureManager().

00050 {
00051         // delete instances.
00052         contReset(_Instances);
00053 
00054         // delete banks.
00055         for(uint i=0;i<_Banks.size();i++)
00056         {
00057                 delete _Banks[i];
00058         }
00059         contReset(_Banks);
00060 }


Field Documentation

std::vector<CHLSTextureBank *> NL3D::CHLSTextureManager::_Banks [private]
 

Definition at line 77 of file hls_texture_manager.h.

Referenced by addBank(), and reset().

std::vector<CHLSTextureBank::CTextureInstanceHandle> NL3D::CHLSTextureManager::_Instances [private]
 

Definition at line 80 of file hls_texture_manager.h.

Referenced by addBank(), buildTexture(), findTexture(), getNumTextures(), getTextureName(), and reset().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:47:10 2004 for NeL by doxygen 1.3.6