# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::ITexture Class Reference

Interface for textures. More...

#include <texture.h>

Inheritance diagram for NL3D::ITexture:

NLMISC::CBitmap NLMISC::CRefCount NLMISC::IStreamable NLMISC::IClassable NL3D::CTextureBlank NL3D::CTextureBlend NL3D::CTextureBump NL3D::CTextureCross NL3D::CTextureCube NL3D::CTextureDLM NL3D::CTextureFar NL3D::CTextureFile NL3D::CTextureFont NL3D::CTextureGrouped NL3D::CTextureMem NL3D::CTextureMultiFile NL3D::CTextureNear List of all members.

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 Methods

void touch ()
 This method invalidates all the texture surface. More...

void touchRect (const NLMISC::CRect &rect)
 This method invalidates a rectangle of the texture surface. More...

bool getReleasable () const
 Return whether texture can be released. More...

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(). More...

void generate ()
 Generate the texture pixels. More...

void validateGenerateFlag ()
 Advanced. More...

virtual void release ()
 Release the texure (free memory). More...

virtual bool supportSharing () const
 Does this texture support sharing system. More...

virtual std::string getShareName () const
 Return the Unique ident/name of the texture, used for Driver sharing caps. More...

bool setupedIntoDriver () const
 Tells if the texture has been setuped by the driver. More...

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

virtual bool allowDegradation () const
 Does this texture allow the driver to degrade. More...

virtual void serial (NLMISC::IStream &f) throw (NLMISC::EStream)
 serial ITexture basic infos (clamp ...). More...

virtual void selectTexture (uint index)
 Select a texture among several other (if this texture is a set of texture such as CTextureMultiFile) The default does nothing. More...

virtual bool isSelectable () const
 Test wether this texture is selectable. More...

virtual ITexture * buildNonSelectableVersion (uint index)
 If this texture is selectable, build a non selectable version of this texture that is setupped with the given slot. More...

bool isAllInvalidated () const
 Return true if ALL the texture is invalidate, else return false. More...

bool touched (void)
 This method return the touched flag. More...

void clearTouched (void)
 ITexture ()
 By default, a texture is releasable. More...

 ITexture (const ITexture &tex)
 see operator=. More...

virtual ~ITexture ()
 Need a virtual dtor. More...

ITexture & operator= (const ITexture &tex)
 The operator= do not copy drv info, and set touched=true. _Releasable, WrapMode and UploadFormat are copied. More...

Texture parameters.
void setWrapS (TWrapMode mode)
void setWrapT (TWrapMode mode)
TWrapMode getWrapS () const
TWrapMode getWrapT () const
void setUploadFormat (TUploadFormat pf)
 Replace the uploaded format of the texture. More...

TUploadFormat getUploadFormat () const
virtual void setFilterMode (TMagFilter magf, TMinFilter minf)
TMagFilter getMagFilter () const
TMinFilter getMinFilter () const
bool mipMapOff () const
bool mipMapOn () const
virtual bool isTextureCube () const
 Does this texture is a cube texture. More...


Public Attributes

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


Protected Methods

virtual void doGenerate ()=0
 Generate the texture pixels. More...


Protected Attributes

bool _Touched

Private Attributes

bool _GoodGenerate
bool _Releasable
TUploadFormat _UploadFormat
TWrapMode _WrapS
TWrapMode _WrapT
TMinFilter _MinFilter
TMagFilter _MagFilter

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 104 of file texture.h.


Member Enumeration Documentation

enum NL3D::ITexture::TMagFilter
 

Magnification mode.

Same behavior as OpenGL.

Enumeration values:
Nearest 
Linear 
MagFilterCount 

Definition at line 140 of file texture.h.

Referenced by getMagFilter.

enum NL3D::ITexture::TMinFilter
 

Minifying mode.

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

Enumeration values:
NearestMipMapOff 
NearestMipMapNearest 
NearestMipMapLinear 
LinearMipMapOff 
LinearMipMapNearest 
LinearMipMapLinear 
MinFilterCount 

Definition at line 151 of file texture.h.

Referenced by getMinFilter.

enum NL3D::ITexture::TUploadFormat
 

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

Definition at line 117 of file texture.h.

Referenced by getUploadFormat.

enum NL3D::ITexture::TWrapMode
 

Enumeration values:
Repeat 
Clamp 
WrapModeCount 

Definition at line 109 of file texture.h.

Referenced by getWrapS, getWrapT, setWrapS, and setWrapT.


Constructor & Destructor Documentation

NL3D::ITexture::ITexture  
 

By default, a texture is releasable.

Definition at line 43 of file texture.cpp.

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

Referenced by NL3D::CTextureMultiFile::buildNonSelectableVersion, NL3D::CTextureCube::buildNonSelectableVersion, buildNonSelectableVersion, NL3D::CTextureCube::doGenerate, NL3D::CTextureBlend::getBlendtexture, NL3D::CTextureBump::getHeightMap, NL3D::CTextureCube::getTexture, and NL3D::CTextureFile::operator=.

NL3D::ITexture::ITexture const ITexture &    tex [inline]
 

see operator=.

Definition at line 171 of file texture.h.

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]
 

Does this texture allow the driver to degrade.

Reimplemented in NL3D::CTextureFile.

Definition at line 338 of file texture.h.

virtual ITexture* NL3D::ITexture::buildNonSelectableVersion uint    index [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.

Definition at line 354 of file texture.h.

References index, and ITexture.

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

Definition at line 430 of file texture.h.

References _Touched.

virtual void NL3D::ITexture::doGenerate   [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::CTextureCross.

Referenced by generate.

void NL3D::ITexture::generate   [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...

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

Definition at line 295 of file texture.h.

References _GoodGenerate, and doGenerate.

TMagFilter NL3D::ITexture::getMagFilter   const [inline]
 

Definition at line 206 of file texture.h.

References _MagFilter, and TMagFilter.

TMinFilter NL3D::ITexture::getMinFilter   const [inline]
 

Definition at line 207 of file texture.h.

References _MinFilter, and TMinFilter.

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 259 of file texture.h.

References _Releasable.

virtual std::string NL3D::ITexture::getShareName   const [inline, virtual]
 

Return the Unique ident/name of the texture, used for Driver sharing caps.

Deriver should add a prefix for their texture type. eg "file::pipoland", "noise::4-4-2" etc....

Reimplemented in NL3D::CTextureBlend.

Definition at line 324 of file texture.h.

TUploadFormat NL3D::ITexture::getUploadFormat   const [inline]
 

Definition at line 204 of file texture.h.

References _UploadFormat, and TUploadFormat.

TWrapMode NL3D::ITexture::getWrapS   const [inline]
 

Definition at line 196 of file texture.h.

References _WrapS, and TWrapMode.

TWrapMode NL3D::ITexture::getWrapT   const [inline]
 

Definition at line 197 of file texture.h.

References _WrapT, and TWrapMode.

bool NL3D::ITexture::isAllInvalidated   const [inline]
 

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

Definition at line 410 of file texture.h.

References _Touched.

Referenced by touchRect.

virtual bool NL3D::ITexture::isSelectable   const [inline, virtual]
 

Test wether this texture is selectable.

Reimplemented in NL3D::CTextureCube.

Definition at line 349 of file texture.h.

virtual bool NL3D::ITexture::isTextureCube   const [inline, virtual]
 

Does this texture is a cube texture.

Reimplemented in NL3D::CTextureCube.

Definition at line 362 of file texture.h.

bool NL3D::ITexture::mipMapOff   const [inline]
 

Definition at line 208 of file texture.h.

References _MinFilter, LinearMipMapOff, and NearestMipMapOff.

Referenced by mipMapOn, and setFilterMode.

bool NL3D::ITexture::mipMapOn   const [inline]
 

Definition at line 209 of file texture.h.

References mipMapOff.

ITexture & NL3D::ITexture::operator= const ITexture &    tex
 

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

Definition at line 72 of file texture.cpp.

References _MagFilter, _MinFilter, _Releasable, _UploadFormat, _WrapS, _WrapT, and touch.

virtual void NL3D::ITexture::release void    [inline, virtual]
 

Release the texure (free memory).

Reimplemented in NL3D::CTextureBlend.

Definition at line 313 of file texture.h.

References _GoodGenerate, and NLMISC::CBitmap::reset.

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< CTextureDrvShare >::kill, and TextureDrvShare.

Referenced by ~ITexture.

virtual void NL3D::ITexture::selectTexture uint    index [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.

Definition at line 346 of file texture.h.

References index.

void NL3D::ITexture::serial NLMISC::IStream   f throw (NLMISC::EStream) [virtual]
 

serial ITexture basic infos (clamp ...).

Implements NLMISC::IStreamable.

Reimplemented in NL3D::CTextureCross.

Definition at line 133 of file texture.cpp.

void NL3D::ITexture::setFilterMode TMagFilter    magf,
TMinFilter    minf
[virtual]
 

Reimplemented in NL3D::CTextureBump.

Definition at line 100 of file texture.cpp.

References _MagFilter, _MinFilter, mipMapOff, and touch.

Referenced by NL3D::CTextureDLM::CTextureDLM, NL3D::CTextureFont::CTextureFont, NL3D::CTextureGrouped::CTextureGrouped, NL3D::CTextureNear::CTextureNear, and NL3D::CTextureFar::setSizeOfFarPatch.

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 270 of file texture.h.

References _Releasable, and r.

Referenced by NL3D::CTextureDLM::CTextureDLM, NL3D::CTextureFar::CTextureFar, NL3D::CTextureFont::CTextureFont, and NL3D::CTextureNear::CTextureNear.

bool NL3D::ITexture::setupedIntoDriver   const [inline]
 

Tells if the texture has been setuped by the driver.

Definition at line 329 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 88 of file texture.cpp.

References _UploadFormat, and touch.

Referenced by NL3D::CTextureDLM::CTextureDLM, NL3D::CTextureFont::CTextureFont, NL3D::CTextureNear::CTextureNear, and NL3D::CTextureFar::setSizeOfFarPatch.

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

  • 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, wether the texture has mipmap or not.

Definition at line 194 of file texture.h.

References _WrapS, and TWrapMode.

Referenced by NL3D::CTextureFont::CTextureFont, and NL3D::CTextureFar::setSizeOfFarPatch.

void NL3D::ITexture::setWrapT TWrapMode    mode [inline]
 

Definition at line 195 of file texture.h.

References _WrapT, and TWrapMode.

Referenced by NL3D::CTextureFont::CTextureFont, and NL3D::CTextureFar::setSizeOfFarPatch.

virtual bool NL3D::ITexture::supportSharing   const [inline, virtual]
 

Does this texture support sharing system.

Reimplemented in NL3D::CTextureBlend.

Definition at line 318 of file texture.h.

Referenced by touchRect.

void NL3D::ITexture::touch   [inline]
 

This method invalidates all the texture surface.

When the driver calls generate, the texture will rebuild all the texture and the driver will update it.

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

Definition at line 219 of file texture.h.

References _GoodGenerate, _ListInvalidRect, and _Touched.

Referenced by NL3D::CTextureFile::CTextureFile, operator=, NL3D::CTextureMultiFile::selectTexture, NL3D::CTextureCube::selectTexture, NL3D::CTextureBlend::setBlendFactor, NL3D::CTextureBlend::setBlendTexture, NL3D::CTextureMultiFile::setFileName, NL3D::CTextureFile::setFileName, setFilterMode, NL3D::CTextureBump::setHeightMap, NL3D::CTextureGrouped::setTextures, and setUploadFormat.

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 420 of file texture.h.

References _Touched.

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).

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

Definition at line 234 of file texture.h.

References _GoodGenerate, _ListInvalidRect, _Touched, isAllInvalidated, nlassert, and supportSharing.

Referenced by NL3D::CTextureFont::getLetterInfo.

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 308 of file texture.h.

References _GoodGenerate.


Member Data Documentation

bool NL3D::ITexture::_GoodGenerate [private]
 

Definition at line 386 of file texture.h.

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

std::list<NLMISC::CRect> NL3D::ITexture::_ListInvalidRect
 

List of invalided rectangle.

If the list is empty, generate() will rebuild all the texture.

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

Definition at line 404 of file texture.h.

Referenced by NL3D::CTextureFont::doGenerate, NL3D::CTextureFar::doGenerate, touch, and touchRect.

TMagFilter NL3D::ITexture::_MagFilter [private]
 

Definition at line 392 of file texture.h.

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

TMinFilter NL3D::ITexture::_MinFilter [private]
 

Definition at line 391 of file texture.h.

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

bool NL3D::ITexture::_Releasable [private]
 

Definition at line 387 of file texture.h.

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

bool NL3D::ITexture::_Touched [protected]
 

Definition at line 369 of file texture.h.

Referenced by clearTouched, isAllInvalidated, ITexture, NL3D::CTextureMem::setPointer, touch, touched, and touchRect.

TUploadFormat NL3D::ITexture::_UploadFormat [private]
 

Definition at line 388 of file texture.h.

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

TWrapMode NL3D::ITexture::_WrapS [private]
 

Definition at line 389 of file texture.h.

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

TWrapMode NL3D::ITexture::_WrapT [private]
 

Definition at line 390 of file texture.h.

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

NLMISC::CRefPtr<CTextureDrvShare> NL3D::ITexture::TextureDrvShare
 

Definition at line 398 of file texture.h.

Referenced by releaseDriverSetup, and setupedIntoDriver.


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