# 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

Inheritance graph
[legend]
Collaboration diagram for NL3D::ITexture:

Collaboration graph
[legend]
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,
  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

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

void setWrapS (TWrapMode mode)
 By default, parameters are: - WrapS==Repeat - WrapT==Repeat - UploadFormat== Auto - MagFilter== Linear. More...

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
void setFilterMode (TMagFilter magf, TMinFilter minf)
TMagFilter getMagFilter () const
TMinFilter getMinFilter () const
bool mipMapOff () const
bool mipMapOn () const
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 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...

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)

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.

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.

enum NL3D::ITexture::TUploadFormat
 

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

Definition at line 117 of file texture.h.

enum NL3D::ITexture::TWrapMode
 

Enumeration values:
Repeat  
Clamp  
WrapModeCount  

Definition at line 109 of file texture.h.


Constructor & Destructor Documentation

NL3D::ITexture::ITexture ( )
 

By default, a texture is releasable.

Definition at line 39 of file texture.cpp.

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 51 of file texture.cpp.


Member Function Documentation

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

Definition at line 395 of file texture.h.

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

Reimplemented in NL3D::CTextureFar, NL3D::CTextureFile, NL3D::CTextureFont, NL3D::CTextureGrouped, NL3D::CTextureMem, NL3D::CTextureNear, and NL3D::CTextureCross.

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.

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

Definition at line 206 of file texture.h.

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

Definition at line 207 of file texture.h.

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.

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::CTextureFile, and NL3D::CTextureGrouped.

Definition at line 319 of file texture.h.

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

Definition at line 204 of file texture.h.

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

Definition at line 196 of file texture.h.

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

Definition at line 197 of file texture.h.

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

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

Definition at line 375 of file texture.h.

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

Definition at line 208 of file texture.h.

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

Definition at line 209 of file texture.h.

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 58 of file texture.cpp.

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

Release the texure (free memory).

Definition at line 308 of file texture.h.

void NL3D::ITexture::setFilterMode ( TMagFilter magf,
TMinFilter minf )
 

Definition at line 84 of file texture.cpp.

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.

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 73 of file texture.cpp.

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

Definition at line 194 of file texture.h.

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

Definition at line 195 of file texture.h.

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

Tells if the texture has been setuped by the driver.

Definition at line 324 of file texture.h.

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

Does this texture support sharing system.

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

Definition at line 313 of file texture.h.

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.

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.

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


Member Data Documentation

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

Definition at line 363 of file texture.h.

bool NL3D::ITexture::_GoodGenerate [private]
 

Definition at line 351 of file texture.h.

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

TMagFilter NL3D::ITexture::_MagFilter [private]
 

Definition at line 357 of file texture.h.

TMinFilter NL3D::ITexture::_MinFilter [private]
 

Definition at line 356 of file texture.h.

bool NL3D::ITexture::_Releasable [private]
 

Definition at line 352 of file texture.h.

bool NL3D::ITexture::_Touched [protected]
 

Definition at line 334 of file texture.h.

TUploadFormat NL3D::ITexture::_UploadFormat [private]
 

Definition at line 353 of file texture.h.

TWrapMode NL3D::ITexture::_WrapS [private]
 

Definition at line 354 of file texture.h.

TWrapMode NL3D::ITexture::_WrapT [private]
 

Definition at line 355 of file texture.h.


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