CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

csTextureHandle Class Reference

This class is the top-level representation of a texture. More...

#include <csplugincommon/render3d/txtmgr.h>

Inheritance diagram for csTextureHandle:

iTextureHandle iBase List of all members.

Public Member Functions

int GetFlags () const
 Get texture usage flags.
void FreeImage ()
 Release the original image (iImage) as given by the engine.
virtual void CreateMipmaps ()
 Create all mipmapped bitmaps from the first level.
virtual void PrepareInt ()
 Merge this texture into current palette, compute mipmaps and so on.
csTextureget_texture (int mipmap)
 Get the texture at the corresponding mipmap level (0..3).
void AdjustSizePo2 ()
 Adjusts the textures size, to ensure some restrictions like power of two dimension are met.
csRGBpixelget_transparent ()
 Get the transparent color as a RGB pixel.
virtual csTextureNewTexture (iImage *Image, bool ismipmap=false)=0
 Create a new texture object (should be implemented by heirs).
virtual void ComputeMeanColor ()=0
 Compute the mean color for the just-created texture.
virtual void Blit (int x, int y, int width, int height, unsigned char const *data)
 Blit a memory block to this texture.
virtual void SetKeyColor (bool Enable)
 Enable transparent color.
virtual void SetKeyColor (uint8 red, uint8 green, uint8 blue)
 Set the transparent color.
virtual bool GetKeyColor () const
 Get the transparent status (false if no transparency, true if transparency).
virtual void GetKeyColor (uint8 &r, uint8 &g, uint8 &b) const
 Get the transparent color.
virtual bool GetRendererDimensions (int &mw, int &mh)
 Get the dimensions for a given mipmap level (0 to 3).
virtual void GetOriginalDimensions (int &w, int &h)
 Return the original dimensions of the image used to create this texture.
virtual void GetMeanColor (uint8 &r, uint8 &g, uint8 &b) const
 Get the mean color.
virtual void * GetCacheData ()
 Get data associated internally with this texture by texture cache.
virtual void SetCacheData (void *d)
 Set data associated internally with this texture by texture cache.
virtual void * GetPrivateObject ()
 Get the csTextureHandle object associated with the texture handle.
virtual bool GetAlphaMap ()
 Query if the texture has an alpha channel.
virtual csAlphaMode::AlphaType GetAlphaType () const
 Get the type of alpha associated with the texture.
virtual void SetAlphaType (csAlphaMode::AlphaType alphaType)
 Set the type of alpha associated with the texture.
virtual void Precache ()
 Precache this texture.
virtual void SetTextureClass (const char *className)
 Set the "class" of this texture.
virtual const char * GetTextureClass ()
 Get the "class" of a texture.

Static Public Member Functions

void CalculateNextBestPo2Size (const int orgDim, int &newDim)
 Given a texture width and height, it tries to 'guesstimate' the po2 size that causes the least quality reduction: it calculates how many rows/columns would be added/removed when sizing up/down, and takes the one with the smaller number.

Public Attributes

 SCF_DECLARE_IBASE
 --------------------- iTextureHandle implementation ----------------------

Protected Attributes

csRef< iImageimage
 The original image object.
csRef< csTextureManagertexman
 Parent texture manager.
int flags
 Texture usage flags: 2d/3d/etc.
csTexturetex [4]
 Texture for mipmap levels 0..3.
void * cachedata
 Texture cache for-internal-use pointer.
bool transp
 Does color 0 mean "transparent" for this texture?
csRGBpixel transp_color
 The transparent color.
csRGBpixel mean_color
 Mean color used when texture mapping is disabled.

Detailed Description

This class is the top-level representation of a texture.

It contains a number of csTexture objects that represents each a single image. A csTexture object is created for each mipmap and for the 2D texture. This class is responsible for creating these textures and filling them with the correct info. The csTextureHandle class is private to the 3D driver, the driver clients see just the iTextureHandle interface.

The handle is initialized by giving the 3D driver a iImage object. Later the renderer will create mipmaps and 2D textures are created. The texture manager will release its reference to the image when no longer needed.

Definition at line 56 of file txtmgr.h.


Member Function Documentation

void csTextureHandle::AdjustSizePo2  ) 
 

Adjusts the textures size, to ensure some restrictions like power of two dimension are met.

virtual void csTextureHandle::Blit int  x,
int  y,
int  width,
int  height,
unsigned char const *  data
[inline, virtual]
 

Blit a memory block to this texture.

Format of the image is RGBA in bytes. Row by row.

Implements iTextureHandle.

Definition at line 124 of file txtmgr.h.

void csTextureHandle::CalculateNextBestPo2Size const int  orgDim,
int &  newDim
[static]
 

Given a texture width and height, it tries to 'guesstimate' the po2 size that causes the least quality reduction: it calculates how many rows/columns would be added/removed when sizing up/down, and takes the one with the smaller number.

In case of a tie, it'll size up.

virtual void csTextureHandle::ComputeMeanColor  )  [pure virtual]
 

Compute the mean color for the just-created texture.

virtual void csTextureHandle::CreateMipmaps  )  [virtual]
 

Create all mipmapped bitmaps from the first level.

void csTextureHandle::FreeImage  ) 
 

Release the original image (iImage) as given by the engine.

csTexture* csTextureHandle::get_texture int  mipmap  )  [inline]
 

Get the texture at the corresponding mipmap level (0..3).

Definition at line 102 of file txtmgr.h.

csRGBpixel* csTextureHandle::get_transparent  )  [inline]
 

Get the transparent color as a RGB pixel.

Definition at line 115 of file txtmgr.h.

virtual bool csTextureHandle::GetAlphaMap  )  [inline, virtual]
 

Query if the texture has an alpha channel.

This depends both on whenever the original image had an alpha channel and of the fact whenever the renderer supports alpha maps at all.

Implements iTextureHandle.

Definition at line 175 of file txtmgr.h.

virtual csAlphaMode::AlphaType csTextureHandle::GetAlphaType  )  const [inline, virtual]
 

Get the type of alpha associated with the texture.

Implements iTextureHandle.

Definition at line 186 of file txtmgr.h.

virtual void* csTextureHandle::GetCacheData  )  [inline, virtual]
 

Get data associated internally with this texture by texture cache.

Implements iTextureHandle.

Definition at line 160 of file txtmgr.h.

int csTextureHandle::GetFlags  )  const [inline, virtual]
 

Get texture usage flags.

Implements iTextureHandle.

Definition at line 88 of file txtmgr.h.

virtual void csTextureHandle::GetKeyColor uint8 r,
uint8 g,
uint8 b
const [virtual]
 

Get the transparent color.

Implements iTextureHandle.

virtual bool csTextureHandle::GetKeyColor  )  const [virtual]
 

Get the transparent status (false if no transparency, true if transparency).

Implements iTextureHandle.

virtual void csTextureHandle::GetMeanColor uint8 r,
uint8 g,
uint8 b
const [virtual]
 

Get the mean color.

Implements iTextureHandle.

virtual void csTextureHandle::GetOriginalDimensions int &  w,
int &  h
[inline, virtual]
 

Return the original dimensions of the image used to create this texture.

This is most often equal to GetMipMapDimensions (0, mw, mh) but in some cases the texture will have been resized in order to accomodate hardware restrictions (like power of two and maximum texture size). This function returns the uncorrected coordinates.

Implements iTextureHandle.

Definition at line 151 of file txtmgr.h.

References iTextureHandle::GetRendererDimensions().

virtual void* csTextureHandle::GetPrivateObject  )  [inline, virtual]
 

Get the csTextureHandle object associated with the texture handle.

Implements iTextureHandle.

Definition at line 167 of file txtmgr.h.

virtual bool csTextureHandle::GetRendererDimensions int &  mw,
int &  mh
[virtual]
 

Get the dimensions for a given mipmap level (0 to 3).

This function is only valid if the texture has been registered for 3D usage.

Implements iTextureHandle.

virtual const char* csTextureHandle::GetTextureClass  )  [virtual]
 

Get the "class" of a texture.

See also:
SetTextureClass

Implements iTextureHandle.

virtual csTexture* csTextureHandle::NewTexture iImage Image,
bool  ismipmap = false
[pure virtual]
 

Create a new texture object (should be implemented by heirs).

virtual void csTextureHandle::Precache  )  [inline, virtual]
 

Precache this texture.

This might free up temporary memory and makes later usage of the texture faster.

Implements iTextureHandle.

Definition at line 191 of file txtmgr.h.

virtual void csTextureHandle::PrepareInt  )  [inline, virtual]
 

Merge this texture into current palette, compute mipmaps and so on.

Definition at line 99 of file txtmgr.h.

virtual void csTextureHandle::SetAlphaType csAlphaMode::AlphaType  alphaType  )  [inline, virtual]
 

Set the type of alpha associated with the texture.

Usually, the alpha mode is auto-detected (alphaSmooth on images with alpha channels, alphaBinary on keycolored images, alphaNone otherwise), but can be overridden with this method.

Implements iTextureHandle.

Definition at line 188 of file txtmgr.h.

virtual void csTextureHandle::SetCacheData void *  d  )  [inline, virtual]
 

Set data associated internally with this texture by texture cache.

Implements iTextureHandle.

Definition at line 163 of file txtmgr.h.

virtual void csTextureHandle::SetKeyColor uint8  red,
uint8  green,
uint8  blue
[virtual]
 

Set the transparent color.

Implements iTextureHandle.

virtual void csTextureHandle::SetKeyColor bool  Enable  )  [virtual]
 

Enable transparent color.

Implements iTextureHandle.

virtual void csTextureHandle::SetTextureClass const char *  className  )  [virtual]
 

Set the "class" of this texture.

A texture class is used to set some characteristics on how a texture is handled at runtime. For example, graphics hardware usually offers texture compression, but it can cause a loss of quality and precision and thus may not be desireable for all data. In this case, a class can be set on the texture that instructs the renderer to not apply texture compression.

Remarks:
Not all renderers may support texture classes.
See also:
GetTextureClass

Implements iTextureHandle.


Member Data Documentation

void* csTextureHandle::cachedata [protected]
 

Texture cache for-internal-use pointer.

Definition at line 71 of file txtmgr.h.

int csTextureHandle::flags [protected]
 

Texture usage flags: 2d/3d/etc.

Definition at line 65 of file txtmgr.h.

csRef<iImage> csTextureHandle::image [protected]
 

The original image object.

Definition at line 60 of file txtmgr.h.

csRGBpixel csTextureHandle::mean_color [protected]
 

Mean color used when texture mapping is disabled.

Definition at line 78 of file txtmgr.h.

csTextureHandle::SCF_DECLARE_IBASE
 

--------------------- iTextureHandle implementation ----------------------

Definition at line 128 of file txtmgr.h.

csTexture* csTextureHandle::tex[4] [protected]
 

Texture for mipmap levels 0..3.

Definition at line 68 of file txtmgr.h.

csRef<csTextureManager> csTextureHandle::texman [protected]
 

Parent texture manager.

Definition at line 62 of file txtmgr.h.

bool csTextureHandle::transp [protected]
 

Does color 0 mean "transparent" for this texture?

Definition at line 74 of file txtmgr.h.

csRGBpixel csTextureHandle::transp_color [protected]
 

The transparent color.

Definition at line 76 of file txtmgr.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.3.9.1