QSDK 1.1 Documentation
Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

Q::Texture Struct Reference
[Shading & LightingAnimation]

A straight 2D texture. More...

#include <Q/q.h>

Inheritance diagram for Q::Texture:

Q::TextureEffect Q::Object Q::ObjectBase List of all members.

Public Types

enum  {
  positionTrack = 0,
  rotationTrack = 1,
  scaleTrack = 2
}

Public Member Functions

 Texture ()
 Texture (const char *name)
Utils::Result setLevel (unsigned int level, const Bitmap &data)
Utils::Result setLowestLoadLevel (unsigned int level)
unsigned int lowestLoadLevel () const
Utils::Result fillFromLevel (unsigned int level, Image::Pixmap *data)
unsigned int levels () const
Bitmap level (unsigned int level) const
Utils::Result setPlayback (const Instance &i, const Shader &s, const Playback &pb)
Playback playback (const Instance &i, const Shader &s) const
Utils::Ref< Image::PixmapreadTopLevel (const Screen &screen) const

Static Public Member Functions

Texture create (const char *name, unsigned int levels, const Database &db=Database())
Texture find (const char *name)
Texture defaultTexture ()
ClassType classType ()
Texture cast (const ObjectBase &)

Detailed Description

A straight 2D texture.

A Texture represents an image used to add surface detail to an object. Due to hardware rendering limitations, the image used must be square and its dimensions must be a power of two. For efficient rendering and to improve rendering quality, multiple versions of the image are kept at different resolutions, with each smaller image half the size of the next larger image. The whole group of images is called a 'mip-map' and each image is referred to as a 'level' within the mip-map. When a texture is loaded to be used for rendering, it starts by just loading the lowest level that has a bitmap assigned to it. It then trickles in higher levels if there is space in the rendering hardware to accomodate them. To change this behaviour use setLowestLoadLevel.

Levels within the mip-map are numbered with indices starting at zero. The level number represents the base-2 logarithm of the mip-level's dimension - i.e. the bitmap for the level must be a square image with a width and height of two to the power of level.

The texture co-ordinates of an Instance of a Mesh using a Shader that uses this texture can be animated by asking the texture for the relevant Playback object and connecting up the required Animation.

See also:
QDemo2 production guide for guidance on how to build and import textures in Q files.


Member Enumeration Documentation

anonymous enum
 

Track numbers for creating animations for textures.


Constructor & Destructor Documentation

Q::Texture::Texture  )  [inline]
 

Create a null texture reference.

Q::Texture::Texture const char *  name  ) 
 

Search the currently attached databases for a texture with the given name.


Member Function Documentation

Texture Q::Texture::cast const ObjectBase  )  [static]
 

If the object referenced by obj is a texture, then return a suitable Texture reference to the object.

Note:
Casting this object will cause it to be loaded from the database if it is not currently resident.

Reimplemented from Q::TextureEffect.

ClassType Q::Texture::classType  )  [static]
 

Return the type for this class.

Texture Q::Texture::create const char *  name,
unsigned int  levels,
const Database db = Database()
[static]
 

Create a new texture named name with levels mip-levels in the database db (or the most recently attached read-write database if db is null).

Texture Q::Texture::defaultTexture  )  [static]
 

Return the default texture, which can be used by exporters to resolve textures that can't be exported for some reason.

Utils::Result Q::Texture::fillFromLevel unsigned int  level,
Image::Pixmap data
 

Temporarily fill the whole mip chain from the mip-level at index level from the pixmap data. This only has an effect if the texture is currently being used on screen.

Texture Q::Texture::find const char *  name  )  [static]
 

Search the currently attached databases for a texture with the given name and return that object, if it exists.

Bitmap Q::Texture::level unsigned int  level  )  const
 

Return the Bitmap for level level.

unsigned int Q::Texture::levels  )  const
 

Return the number of mip-levels in the texture.

unsigned int Q::Texture::lowestLoadLevel  )  const
 

Return the lowest level to start loading from.

See also:
setLowestLoadLevel()

Playback Q::Texture::playback const Instance i,
const Shader s
const
 

Return the playback currently used for animating a given instance of the texture.

Utils::Ref<Image::Pixmap> Q::Texture::readTopLevel const Screen screen  )  const
 

Read the contents of the top mip-level of the texture.

Utils::Result Q::Texture::setLevel unsigned int  level,
const Bitmap data
 

Set the mip-level at index level to the bitmap data. The top level of the texture, must have a bitmap assigned to it and for any other level that has a bitmap assigned to it, all higher levels must also have an assigned bitmap.

Utils::Result Q::Texture::setLowestLoadLevel unsigned int  level  ) 
 

Set the lowest level to start loading from. This must be a level that has a bitmap assigned to it. By default this is the smallest such level.

Utils::Result Q::Texture::setPlayback const Instance i,
const Shader s,
const Playback pb
 

Set the playback object used to animate an instance of the texture. Animations for textures should have three tracks, one for each of its position, rotation and scale respectively. The track numbers to be used for recording an Animation which is compatible with a texture are Texture::positionTrack, Texture::rotationTrack and Texture::scaleTrack.

Note:
It is possible to seek a Texture by setting a playback and calling Playback::seek. Because textures do not retain animation changes, it is not possible to seek a Texture without a Playback. Setting an invalid playback resets the texture.

Return to QSDK documentation Contents page. Contact details for support, information and fault-reporting.
Qube Software Limited © 2000-2004