NL3D::ITexture Class Reference

Interface for textures. More...

#include <texture.h>

Inherits NLMISC::CBitmap, NLMISC::CRefCount, and NLMISC::IStreamable.

Inherited by NL3D::CTextureBlank, NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCross, NL3D::CTextureCube, NL3D::CTextureDLM, NL3D::CTextureEmboss, NL3D::CTextureFar, NL3D::CTextureFile, NL3D::CTextureFont, NL3D::CTextureGrouped, NL3D::CTextureMem, NL3D::CTextureMultiFile, and NL3D::CTextureNear.

List of all members.

Classes

class  CTextureCategory
 Category String. More...

Public Types

enum  TWrapMode { Repeat = 0, Clamp, WrapModeCount }
enum  TUploadFormat {
  Auto = 0, RGBA8888, RGBA4444, RGBA5551,
  RGB888, RGB565, DXTC1, DXTC1Alpha,
  DXTC3, DXTC5, Luminance, Alpha,
  AlphaLuminance, DsDt, UploadFormatCount
}
enum  TMagFilter { Nearest = 0, Linear, MagFilterCount }
 

Magnification mode.

More...
enum  TMinFilter {
  NearestMipMapOff = 0, NearestMipMapNearest, NearestMipMapLinear, LinearMipMapOff,
  LinearMipMapNearest, LinearMipMapLinear, MinFilterCount
}
 

Minifying mode.

More...

Public Member Functions

void touch ()
 This method invalidates all the texture surface.
void touchRect (const NLMISC::CRect &rect)
 This method invalidates a rectangle of the texture surface.
bool getReleasable () const
 Return whether texture can be released.
void setReleasable (bool r)
 Set if texture can be released If it is true, the driver will release the texture after generating it and upload it into the videomemory by calling release().
void generate (bool async=false)
 Generate the texture pixels.
void validateGenerateFlag ()
 Advanced.
virtual void release ()
 Release the texure (free memory).
virtual bool supportSharing () const
 Does this texture support sharing system.
virtual std::string getShareName () const
 Return the Unique ident/name of the texture, used for Driver sharing caps.
bool setupedIntoDriver () const
 Tells if the texture has been setuped by the driver.
void releaseDriverSetup ()
 Release the Driver info for this texture (if any). Call it with care.
virtual bool allowDegradation () const
 Does this texture allow the driver to degrade.
virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serial ITexture basic infos (clamp ...).
virtual void selectTexture (uint)
 Select a texture among several other (if this texture is a set of texture such as CTextureMultiFile) The default does nothing.
virtual bool isSelectable () const
 Test whether this texture is selectable.
virtual ITexturebuildNonSelectableVersion (uint)
 If this texture is selectable, build a non selectable version of this texture that is setupped with the given slot.
virtual bool isBumpMap () const
virtual bool isBloomTexture () const
void setTextureCategory (NLMISC::CSmartPtr< CTextureCategory > &textCat)
void setRenderTarget (bool enable)
 Render target texture Active / disable render target abilities for this texture.
bool getRenderTarget () const
 Render target texture Get render target abilities for this texture.
CTextureCategorygetTextureCategory () const
bool isAllInvalidated () const
 Return true if ALL the texture is invalidate, else return false.
bool touched (void)
 This method return the touched flag.
bool filterOrWrapModeTouched () const
 See if filter mode or wrap mode have been touched.
void clearTouched (void)
void clearFilterOrWrapModeTouched ()



 ITexture ()
 Object.
 ITexture (const ITexture &tex)
 see operator=.
virtual ~ITexture ()
 Need a virtual dtor.
ITextureoperator= (const ITexture &tex)
 The operator= do not copy drv info, and set touched=true. _Releasable, WrapMode and UploadFormat are copied.
virtual bool isTextureCube () const
 Cubic textures.
Texture parameters.



void setWrapS (TWrapMode mode)
 By default, parameters are:

  • WrapS==Repeat
  • WrapT==Repeat
  • UploadFormat== Auto
  • MagFilter== Linear.

void setWrapT (TWrapMode mode)
TWrapMode getWrapS () const
TWrapMode getWrapT () const
void setUploadFormat (TUploadFormat pf)
 Replace the uploaded format of the texture.
TUploadFormat getUploadFormat () const
virtual void setFilterMode (TMagFilter magf, TMinFilter minf)
TMagFilter getMagFilter () const
TMinFilter getMinFilter () const
bool mipMapOff () const
bool mipMapOn () const

Public Attributes

NLMISC::CRefPtr< CTextureDrvShareTextureDrvShare
std::list< NLMISC::CRect_ListInvalidRect
 List of invalided rectangle.

Protected Member Functions

virtual void doGenerate (bool async=false)=0
 Generate the texture pixels.

Protected Attributes

bool _Touched: 1
bool _FilterOrWrapModeTouched: 1

Private Attributes

bool _GoodGenerate
bool _Releasable
bool _RenderTarget
TUploadFormat _UploadFormat
TWrapMode _WrapS
TWrapMode _WrapT
TMinFilter _MinFilter
TMagFilter _MagFilter
NLMISC::CSmartPtr
< CTextureCategory
_TextureCategory

Detailed Description

Interface for textures.

Sharing System note: The deriver may implement sharing system by implement supportSharing() and getShareName(). Such a texture may return a Unique Name for sharing. If the driver already has this texture, it will reuse it. As a direct impact, you cannot invalidate part of the textures with shared texture. This is logic, since the Unique sharname of the texture must represent all of it.

Definition at line 113 of file texture.h.


Member Enumeration Documentation

Magnification mode.

Same behavior as OpenGL.

Enumerator:
Nearest 
Linear 
MagFilterCount 

Definition at line 149 of file texture.h.

Minifying mode.

Same behavior as OpenGL. If the bitmap has no mipmap, and mipmap is required, then mipmaps are computed.

Enumerator:
NearestMipMapOff 
NearestMipMapNearest 
NearestMipMapLinear 
LinearMipMapOff 
LinearMipMapNearest 
LinearMipMapLinear 
MinFilterCount 

Definition at line 160 of file texture.h.

Enumerator:
Auto 
RGBA8888 
RGBA4444 
RGBA5551 
RGB888 
RGB565 
DXTC1 
DXTC1Alpha 
DXTC3 
DXTC5 
Luminance 
Alpha 
AlphaLuminance 
DsDt 
UploadFormatCount 

Definition at line 126 of file texture.h.

Enumerator:
Repeat 
Clamp 
WrapModeCount 

Definition at line 118 of file texture.h.


Constructor & Destructor Documentation

NL3D::ITexture::ITexture (  ) 

Object.

By default, a texture is releasable.

Definition at line 41 of file texture.cpp.

References _FilterOrWrapModeTouched, _GoodGenerate, _MagFilter, _MinFilter, _Releasable, _RenderTarget, _Touched, _UploadFormat, _WrapS, _WrapT, Auto, Linear, LinearMipMapLinear, and Repeat.

NL3D::ITexture::ITexture ( const ITexture tex  )  [inline]

see operator=.

Definition at line 190 of file texture.h.

References operator=().

NL3D::ITexture::~ITexture (  )  [virtual]

Need a virtual dtor.

Definition at line 56 of file texture.cpp.

References releaseDriverSetup().


Member Function Documentation

virtual bool NL3D::ITexture::allowDegradation (  )  const [inline, virtual]
virtual ITexture* NL3D::ITexture::buildNonSelectableVersion ( uint   )  [inline, virtual]

If this texture is selectable, build a non selectable version of this texture that is setupped with the given slot.

NB : If this texture is selectable, you are ensured that the return pointer is not 'this'

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 382 of file texture.h.

Referenced by NL3D::CMeshBaseInstance::selectTextureSet().

void NL3D::ITexture::clearFilterOrWrapModeTouched (  )  [inline]

Definition at line 495 of file texture.h.

References _FilterOrWrapModeTouched.

Referenced by NL3D::CDriverGL::setupTextureBasicParameters().

void NL3D::ITexture::clearTouched ( void   )  [inline]

Definition at line 489 of file texture.h.

References _ListInvalidRect, and _Touched.

Referenced by NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverD3D::setupTextureEx().

virtual void NL3D::ITexture::doGenerate ( bool  async = false  )  [protected, pure virtual]

Generate the texture pixels.

If the invalidate rect list is empty, generate() must rebuild all the texture. If the invalidate rect list is not empty, generate() rebuilds only the invalidate rectangles in the list.

See also:
isAllInvalidated(), touch(), touched(), touchRect(), clearTouched(), _ListInvalidRect, generate()
getReleasable(), setReleasable()

Implemented in NL3D::CTextureBlank, NL3D::CTextureBlend, NL3D::CTextureBump, NL3D::CTextureCube, NL3D::CTextureDLM, NL3D::CTextureEmboss, NL3D::CTextureFar, NL3D::CTextureFile, NL3D::CTextureFont, NL3D::CTextureGrouped, NL3D::CTextureMem, NL3D::CTextureMultiFile, NL3D::CTextureNear, and NL3D::CTextureCross.

Referenced by generate().

bool NL3D::ITexture::filterOrWrapModeTouched (  )  const [inline]

See if filter mode or wrap mode have been touched.

If this is the case, the driver should resetup them for that texture (If driver stores filter & wrap mode per texture (OpenGL) rather than globally (D3D))

Definition at line 482 of file texture.h.

References _FilterOrWrapModeTouched.

Referenced by NL3D::CDriverGL::setupTextureEx().

void NL3D::ITexture::generate ( bool  async = false  )  [inline]

Generate the texture pixels.

This method is called by the driver when it needs to generate pixels of the texture. If the texture is used for the first time or if it is touched, the driver will call this method. For exemple, a texture file will load the bitmap in this method.

If the invalidate rect list is empty, generate() rebuild all the texture. If the invalidate rect list is not empty, generate() rebuilds only the invalidate rectangles in the list.

Don't clear the touch flag or the invalid rectangle list until updating the texture in generate(). It's the generate()'s caller jobs.

After generation, if the texture is releasable, the driver will release the texture by calling release().

NB: a flag is maintained to see if the generated bitmap is coherent with texture description (see touch*()). So if you do {generate(); generate();}, you only get 1 real bitmap generation...

If, after the doGenerate, the bitmap format is compressed (DXTC) and no mipmaps have been generated, the mipmap are disabled beacause the user probably don't want the driver to unpacks the texture, generates the mipmaps and repacks the dxtc texture (that takes a lot of CPU time).

Parameters:
async tells the texture if the call is made asynchronously or not.
See also:
isAllInvalidated(), touch(), touched(), touchRect(), clearTouched(), _ListInvalidRect
getReleasable(), setReleasable()

Definition at line 323 of file texture.h.

References _GoodGenerate, and doGenerate().

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CTextureCube::doGenerate(), NL3D::CDriverD3D::generateD3DTexture(), NL3D::CZoneLighter::getTexture(), NL3D::GetTextureSize(), NL3D::CTileBank::getTileNoiseMap(), NL3D::CZoneLighter::lightWater(), CEGUI::NeLTexture::loadFromMemory(), NL3D::CAsyncFileManager3D::CTextureLoad::run(), NL3D::CAsyncFileManager3D::CMeshLoad::run(), NL3D::CPSMultiTexturedParticle::setupMaterial(), and NL3D::CDriverGL::setupTextureEx().

TMagFilter NL3D::ITexture::getMagFilter (  )  const [inline]
TMinFilter NL3D::ITexture::getMinFilter (  )  const [inline]
bool NL3D::ITexture::getReleasable (  )  const [inline]

Return whether texture can be released.

If it returns true, the driver will release the texture after generate it and upload it into the videomemory by calling release(). If it returns false, the driver won't release the texture.

Returns:
true if texture can be released, false else
See also:
setReleasable(), generate()

Definition at line 281 of file texture.h.

References _Releasable.

Referenced by NL3D::CTextureGrouped::areValid(), NL3D::CTextureGrouped::doGenerate(), NL3D::CTextureBump::getNormalizationFactor(), NL3D::GetTextureSize(), NL3D::CShapeBank::processWaitingShapes(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CTextureGrouped::release(), NL3D::CTextureBlend::release(), NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverD3D::setupTextureEx(), and NL3D::CAsyncTextureManager::uploadTexturePart().

bool NL3D::ITexture::getRenderTarget (  )  const [inline]

Render target texture Get render target abilities for this texture.

Definition at line 410 of file texture.h.

References _RenderTarget.

Referenced by NL3D::CDriverD3D::generateD3DTexture(), NL3D::CDriverGL::setRenderTarget(), NL3D::CDriverD3D::setRenderTarget(), and NL3D::CDriverD3D::setupTextureEx().

virtual std::string NL3D::ITexture::getShareName (  )  const [inline, virtual]
CTextureCategory* NL3D::ITexture::getTextureCategory (  )  const [inline]

Definition at line 413 of file texture.h.

References _TextureCategory.

Referenced by NL3D::IDriver::profileTextureUsage().

TUploadFormat NL3D::ITexture::getUploadFormat (  )  const [inline]
TWrapMode NL3D::ITexture::getWrapS (  )  const [inline]
TWrapMode NL3D::ITexture::getWrapT (  )  const [inline]
bool NL3D::ITexture::isAllInvalidated (  )  const [inline]

Return true if ALL the texture is invalidate, else return false.

Definition at line 463 of file texture.h.

References _ListInvalidRect, and _Touched.

Referenced by NL3D::CDriverGL::setupTextureEx(), NL3D::CDriverD3D::setupTextureEx(), and touchRect().

virtual bool NL3D::ITexture::isBloomTexture (  )  const [inline, virtual]
virtual bool NL3D::ITexture::isBumpMap (  )  const [inline, virtual]
virtual bool NL3D::ITexture::isSelectable (  )  const [inline, virtual]

Test whether this texture is selectable.

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 377 of file texture.h.

Referenced by NL3D::CMeshBaseInstance::selectTextureSet().

virtual bool NL3D::ITexture::isTextureCube (  )  const [inline, virtual]
bool NL3D::ITexture::mipMapOff (  )  const [inline]
bool NL3D::ITexture::mipMapOn (  )  const [inline]
ITexture & NL3D::ITexture::operator= ( const ITexture tex  ) 

The operator= do not copy drv info, and set touched=true. _Releasable, WrapMode and UploadFormat are copied.

Reimplemented from NLMISC::CBitmap.

Reimplemented in NL3D::CTextureFile, and NL3D::CTextureGrouped.

Definition at line 72 of file texture.cpp.

References _FilterOrWrapModeTouched, _MagFilter, _MinFilter, _Releasable, _RenderTarget, _UploadFormat, _WrapS, _WrapT, and touch().

Referenced by ITexture().

virtual void NL3D::ITexture::release ( void   )  [inline, virtual]
void NL3D::ITexture::releaseDriverSetup (  ) 

Release the Driver info for this texture (if any). Call it with care.

Definition at line 64 of file texture.cpp.

References NLMISC::CRefPtr< T >::kill(), and TextureDrvShare.

Referenced by NL3D::CMeshBaseInstance::isAsyncTextureReady(), and ~ITexture().

virtual void NL3D::ITexture::selectTexture ( uint   )  [inline, virtual]

Select a texture among several other (if this texture is a set of texture such as CTextureMultiFile) The default does nothing.

Reimplemented in NL3D::CTextureCube, and NL3D::CTextureMultiFile.

Definition at line 374 of file texture.h.

Referenced by NL3D::CCoarseMeshBuild::buildBitmap(), NL3D::CCoarseMeshBuild::remapCoordinates(), and NL3D::CAsyncFileManager3D::CMeshLoad::run().

void NL3D::ITexture::serial ( NLMISC::IStream f  )  throw (NLMISC::EStream) [virtual]
void NL3D::ITexture::setFilterMode ( TMagFilter  magf,
TMinFilter  minf 
) [virtual]
void NL3D::ITexture::setReleasable ( bool  r  )  [inline]

Set if texture can be released If it is true, the driver will release the texture after generating it and upload it into the videomemory by calling release().

If it is false, the driver won't release the texture.

See also:
getReleasable(), generate()
Parameters:
true if texture can be released, false else

Definition at line 292 of file texture.h.

References _Releasable.

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), CEGUI::NeLTexture::loadFromMemory(), NL3D::CShapeBank::processWSUploadTexture(), NL3D::CWaterPoolManager::releaseBlendTextures(), NL3D::CWaterPoolManager::setBlendFactor(), and NL3D::CAsyncTextureManager::uploadTexturePart().

void NL3D::ITexture::setRenderTarget ( bool  enable  ) 

Render target texture Active / disable render target abilities for this texture.

Definition at line 165 of file texture.cpp.

References _RenderTarget, and touch().

Referenced by NL3D::CShadowMapManager::allocateTexture(), and NL3D::CDriverD3D::getSurfaceTexture().

void NL3D::ITexture::setTextureCategory ( NLMISC::CSmartPtr< CTextureCategory > &  textCat  )  [inline]
bool NL3D::ITexture::setupedIntoDriver (  )  const [inline]

Tells if the texture has been setuped by the driver.

Definition at line 357 of file texture.h.

References TextureDrvShare.

void NL3D::ITexture::setUploadFormat ( TUploadFormat  pf  ) 

Replace the uploaded format of the texture.

If "Auto", the driver use CBitmap::getPixelFormat() to find the best associated pixelFormat. When no alpha is wanted (RGB, Luminance....), texture default output is 1.0. For "Alpha" mode, RGB output is (0,0,0).

Definition at line 90 of file texture.cpp.

References _UploadFormat, and touch().

Referenced by NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CTextureNear::CTextureNear(), NL3D::CLandscape::findTileTexture(), NL3D::CDriverGL::getSpecularCubeMap(), NL3D::CDriverD3D::setupMaterial(), and NL3D::CDriverGL::setupWaterPassARB().

void NL3D::ITexture::setWrapS ( TWrapMode  mode  )  [inline]

By default, parameters are:

  • WrapS==Repeat
  • WrapT==Repeat
  • UploadFormat== Auto
  • MagFilter== Linear.

  • MinFilter= LinearMipMapLinear.

NB: if multiple ITexture acces the same data via the sharing system (such as a CTextureFile), then:

  • WrapS/WrapT is LOCAL for each ITexture (ie each ITexture will have his own Wrap mode) => no duplication is made.
  • UploadFormat may duplicate the texture in video memory. There is one texture per different UploadFormat.
  • MinFilter may duplicate the texture in video memory in the same way, whether the texture has mipmap or not.

Definition at line 503 of file texture.h.

References _FilterOrWrapModeTouched, and _WrapS.

Referenced by NL3D::CShadowMapManager::allocateTexture(), NL3D::CTextureDLM::CTextureDLM(), NL3D::CTextureFar::CTextureFar(), NL3D::CTextureFont::CTextureFont(), NL3D::CLandscape::findTileTexture(), CEGUI::NeLTexture::loadFromMemory(), NL3D::CVegetableManager::loadTexture(), NL3D::CPSRibbonLookAt::serial(), NL3D::CSegRemanenceShape::setupMaterial(), NL3D::UInstanceMaterial::setWrapS(), and NL3D::CPSQuad::updateTexWrapMode().

void NL3D::ITexture::setWrapT ( TWrapMode  mode  )  [inline]
virtual bool NL3D::ITexture::supportSharing (  )  const [inline, virtual]
void NL3D::ITexture::touch (  )  [inline]
bool NL3D::ITexture::touched ( void   )  [inline]

This method return the touched flag.

If it is true, the driver will call generate to rebuild the texture.

See also:
isAllInvalidated(), generate(), touch(), touchRect(), _ListInvalidRect

Definition at line 473 of file texture.h.

References _Touched.

Referenced by NL3D::CDriverGL::setupTextureEx(), and NL3D::CDriverD3D::setupTextureEx().

void NL3D::ITexture::touchRect ( const NLMISC::CRect rect  )  [inline]

This method invalidates a rectangle of the texture surface.

When the driver calls generate, the texture could rebuild only this part of texture and the driver will update only those rectangles.

This method is incompatible with textures which support sharing (see class description). This method is incompatible with compressed textures. This method is incompatible with cube textures.

See also:
isAllInvalidated(), generate(), touch(), touched(), _ListInvalidRect

Definition at line 255 of file texture.h.

References _GoodGenerate, _ListInvalidRect, _Touched, isAllInvalidated(), isTextureCube(), nlassert, and supportSharing().

Referenced by NL3D::CTextureFar::allocatePatch(), NL3D::CTextureDLM::copyRect(), NL3D::CTextureDLM::fillRect(), NL3D::CTextureFont::getLetterInfo(), NL3D::CTextureDLM::modulateAndfillRect565(), NL3D::CTextureDLM::modulateAndfillRect8888(), NL3D::CTextureDLM::modulateConstantAndfillRect(), NL3D::CTextureNear::refillRect(), and NL3D::CTextureFar::touchPatchULAndNext().

void NL3D::ITexture::validateGenerateFlag (  )  [inline]

Advanced.

erase the _GoodGenerate=true. Special if you want to setup directly the bitmap without using generate(). USE IT WITH CARE!! (used by the CAsyncTextureManager)

Definition at line 336 of file texture.h.

References _GoodGenerate.


Member Data Documentation

Definition at line 437 of file texture.h.

Referenced by generate(), ITexture(), release(), touch(), touchRect(), and validateGenerateFlag().

Definition at line 444 of file texture.h.

Referenced by getMagFilter(), ITexture(), operator=(), and setFilterMode().

Definition at line 443 of file texture.h.

Referenced by getMinFilter(), ITexture(), mipMapOff(), operator=(), and setFilterMode().

Definition at line 438 of file texture.h.

Referenced by getReleasable(), ITexture(), operator=(), and setReleasable().

Definition at line 439 of file texture.h.

Referenced by getRenderTarget(), ITexture(), operator=(), and setRenderTarget().

Definition at line 445 of file texture.h.

Referenced by getTextureCategory(), and setTextureCategory().

Definition at line 440 of file texture.h.

Referenced by getUploadFormat(), ITexture(), operator=(), and setUploadFormat().

Definition at line 441 of file texture.h.

Referenced by getWrapS(), ITexture(), operator=(), and setWrapS().

Definition at line 442 of file texture.h.

Referenced by getWrapT(), ITexture(), operator=(), and setWrapT().


The documentation for this class was generated from the following files:

Generated on Thu Jan 7 08:30:11 2010 for NeL by  doxygen 1.6.1