Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
om::graphics::textures::Texture Class Reference

A class that represents an image stored on the graphics hardware. More...

#include <omGraphicsTexture.h>

Inheritance diagram for om::graphics::textures::Texture:
om::graphics::devices::GraphicsContextObject

Public Member Functions

 Texture ()
 Create a dimensionless texture object with no pixel data. More...
 
 Texture (Size width, Bool isCubeMap=false)
 Create a 1D or cube-map texture object with the specified pixel type and width and no pixel data. More...
 
 Texture (Size width, Size height)
 Create a 2D texture object with the specified pixel type, width and height and no pixel data. More...
 
 Texture (Size width, Size height, Size depth)
 Create a 3D texture object with the specified pixel type, width, height and depth and no pixel data. More...
 
 Texture (Image *newImage)
 Create a new texture object with the specified image for its front face. More...
 
 Texture (devices::GraphicsContext *context, const TextureFormat &format, Size width, Bool isCubeMap=false)
 Create a 1D or cube-map texture object with the specified pixel type and width and no pixel data. More...
 
 Texture (devices::GraphicsContext *context, const TextureFormat &format, Size width, Size height)
 Create a 2D texture object with the specified pixel type, width and height and no pixel data. More...
 
 Texture (devices::GraphicsContext *context, const TextureFormat &format, Size width, Size height, Size depth)
 Create a 3D texture object with the specified pixel type, width, height and depth and no pixel data. More...
 
 Texture (devices::GraphicsContext *context, const TextureFormat &format, Image *newImage)
 Create a new texture object with the specified image for its front face. More...
 
const TextureFormatgetFormat () const
 Return an object that represents the internal storage format that should be used for the texture. More...
 
void setFormat (const TextureFormat &newFormat)
 Set the internal storage format that should be used for the texture. More...
 
Bool hasAlpha () const
 Return whether or not this texture has any face images that have an alpha channel. More...
 
Size getDimensionCount () const
 Return the number of dimensions in this texture, usually 1, 2, or 3. More...
 
Size getWidth () const
 Return the size of the texture along the X direction (dimension 0). More...
 
Size getHeight () const
 Return the size of the texture along the Y direction (dimension 1). More...
 
Size getDepth () const
 Return the size of the texture along the Z direction (dimension 2). More...
 
Size getSize (Index dimension) const
 Return the size of the texture along the specified dimension index. More...
 
Size getTexelCount () const
 Return the total number of texels in the texture. More...
 
Size getFaceCount () const
 Return the number of faces that this texture has. More...
 
Bool isCube () const
 Return whether or not this texture is a cube map texture. More...
 
Bool isValidFace (const TextureFace &face) const
 Return whether or not the specified face is valid for this texture. More...
 
TextureType getType () const
 Return an object describing the high-level type of this texture. More...
 
Bool getFace (Image *&image, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0) const
 Get the texture's image data for the specified face index with the data in the default pixel type. More...
 
Bool getFace (Image *&image, const PixelFormat &pixelType, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0) const
 Get the texture's image data for the specified face index with the data in the specified pixel type. More...
 
Bool setFace (Image *newImage, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0)
 Replace the current contents of the texture with the specified image. More...
 
Bool updateFace (const Image &newImage, Int position, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0)
 Update a region of the texture with the specified image. More...
 
Bool updateFace (const Image &newImage, const Vector2i &position, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0)
 Update a region of the texture with the specified image. More...
 
Bool updateFace (const Image &newImage, const Vector3i &position, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0)
 Update a region of the texture with the specified image. More...
 
Bool clearFace (Float channelColor, TextureFace face=TextureFace::FRONT, Index mipmapLevel=0)
 Clear this texture's image using the specified clear color component for the given face and mipmap level. More...
 
TextureWrapType getWrapType () const
 Return the type of texture wrapping to do when texture coordinates are outside of the range [0,1]. More...
 
void setWrapType (const TextureWrapType &newWrapType)
 Set the type of texture wrapping to do when texture coordinates are outside of the range [0,1]. More...
 
TextureFilter getDownsampleFilter () const
 Return the type of texture filtering that is used when the texture is reduced in size. More...
 
void setDownsampleFilter (const TextureFilter &newDownsampleFilter)
 Set the type of texture filtering that is used when the texture is reduced in size. More...
 
TextureFilter getUpsampleFilter () const
 Return the type of texture filtering that is used when the texture is increased in size. More...
 
void setUpsampleFilter (const TextureFilter &newUpsampleFilter)
 Set the type of texture filtering that is used when the texture is increased in size. More...
 
Size getMipmapCount (const TextureFace &face=TextureFace::FRONT) const
 Return the number of mipmaps that there are for the specified texture face. More...
 
Bool generateMipmaps ()
 Generate smaller mipmaps of the texture from the largest texture image (level 0). More...
 
TextureFlagsgetFlags ()
 Return a reference to an object that contains boolean parameters of the texture. More...
 
const TextureFlagsgetFlags () const
 Return an object that contains boolean parameters of the texture. More...
 
void setFlags (const TextureFlags &newFlags)
 Set an object that contains boolean parameters of the texture. More...
 
Bool flagIsSet (TextureFlags::Flag flag) const
 Return whether or not the specified boolan flag is set for this texture. More...
 
void setFlag (TextureFlags::Flag flag, Bool newIsSet=true)
 Set whether or not the specified boolan flag is set for this texture. More...
 
virtual void setContext (devices::GraphicsContext *newContext)
 Set a pointer to the graphics context this texture should use to do rendering. More...
 
virtual void upload (UploadRequest &request)
 Upload this texture's CPU representation to the GPU device. More...
 
virtual void download (DownloadRequest &request)
 Download the texture's GPU representation to CPU memory. More...
 
virtual Bool isUploaded () const
 Return whether or not this texture has been successfully created and uploaded to the device. More...
 
virtual Bool isDownloaded () const
 Return whether or not this texture has a copy of its data stored in CPU-side memory. More...
 
virtual Bool isValid () const
 Return whether or not the state of this texture is valid (either on CPU or GPU) and able to be used for rendering. More...
 
const DeviceTexturegetRenderable () const
 Return a pointer to the context-renderable texture for this texture, or NULL if there is none. More...
 
const Shared< DeviceTexture > & getSharedRenderable () const
 Return a shared pointer to the context-renderable texture for this texture, or NULL if there is none. More...
 
- Public Member Functions inherited from om::graphics::devices::GraphicsContextObject
virtual ~GraphicsContextObject ()
 Destory this graphics context object. More...
 
GraphicsContextgetContext () const
 Return a pointer to the graphics context this context object is using to do rendering. More...
 
void clearContext ()
 Clear the previous context from this object. More...
 
void upload ()
 Upload this resource's CPU representation to the GPU device. More...
 
void download ()
 Upload this resource's CPU representation to the GPU device. More...
 

Static Public Member Functions

static Size getMaxFaceCount ()
 Return the maximum number of faces that a texture can have. More...
 

Static Public Attributes

static const ResourceType RESOURCE_TYPE
 The resource type for a graphics texture. More...
 

Additional Inherited Members

- Protected Member Functions inherited from om::graphics::devices::GraphicsContextObject
 GraphicsContextObject ()
 Create a new graphics context object that doesn't have an associated graphics context. More...
 
 GraphicsContextObject (GraphicsContext *newContext)
 Create a new graphics context object that uses the specified context for rendering. More...
 
- Protected Attributes inherited from om::graphics::devices::GraphicsContextObject
GraphicsContextcontext
 A pointer to the graphics context this object is using. More...
 

Detailed Description

A class that represents an image stored on the graphics hardware.

A texture can be either 1D, 2D, 3D, or a cube map (six 2D faces), with any common texture format (Alpha, Gray, RGB, RGBA, etc.).

Constructor & Destructor Documentation

om::graphics::textures::Texture::Texture ( )

Create a dimensionless texture object with no pixel data.

om::graphics::textures::Texture::Texture ( Size  width,
Bool  isCubeMap = false 
)

Create a 1D or cube-map texture object with the specified pixel type and width and no pixel data.

om::graphics::textures::Texture::Texture ( Size  width,
Size  height 
)

Create a 2D texture object with the specified pixel type, width and height and no pixel data.

om::graphics::textures::Texture::Texture ( Size  width,
Size  height,
Size  depth 
)

Create a 3D texture object with the specified pixel type, width, height and depth and no pixel data.

om::graphics::textures::Texture::Texture ( Image *  newImage)

Create a new texture object with the specified image for its front face.

om::graphics::textures::Texture::Texture ( devices::GraphicsContext context,
const TextureFormat format,
Size  width,
Bool  isCubeMap = false 
)

Create a 1D or cube-map texture object with the specified pixel type and width and no pixel data.

om::graphics::textures::Texture::Texture ( devices::GraphicsContext context,
const TextureFormat format,
Size  width,
Size  height 
)

Create a 2D texture object with the specified pixel type, width and height and no pixel data.

om::graphics::textures::Texture::Texture ( devices::GraphicsContext context,
const TextureFormat format,
Size  width,
Size  height,
Size  depth 
)

Create a 3D texture object with the specified pixel type, width, height and depth and no pixel data.

om::graphics::textures::Texture::Texture ( devices::GraphicsContext context,
const TextureFormat format,
Image *  newImage 
)

Create a new texture object with the specified image for its front face.

Member Function Documentation

const TextureFormat& om::graphics::textures::Texture::getFormat ( ) const
inline

Return an object that represents the internal storage format that should be used for the texture.

void om::graphics::textures::Texture::setFormat ( const TextureFormat newFormat)
inline

Set the internal storage format that should be used for the texture.

Bool om::graphics::textures::Texture::hasAlpha ( ) const

Return whether or not this texture has any face images that have an alpha channel.

Size om::graphics::textures::Texture::getDimensionCount ( ) const
inline

Return the number of dimensions in this texture, usually 1, 2, or 3.

Size om::graphics::textures::Texture::getWidth ( ) const
inline

Return the size of the texture along the X direction (dimension 0).

Size om::graphics::textures::Texture::getHeight ( ) const
inline

Return the size of the texture along the Y direction (dimension 1).

Size om::graphics::textures::Texture::getDepth ( ) const
inline

Return the size of the texture along the Z direction (dimension 2).

Size om::graphics::textures::Texture::getSize ( Index  dimension) const
inline

Return the size of the texture along the specified dimension index.

Indices start from 0 and count to d-1 for a texture with d dimensions. The method returns a size of 1 for all out-of-bounds dimensions.

Size om::graphics::textures::Texture::getTexelCount ( ) const

Return the total number of texels in the texture.

Size om::graphics::textures::Texture::getFaceCount ( ) const
inline

Return the number of faces that this texture has.

A normal texture will have 1 face, while a cube map texture will have 6 faces.

static Size om::graphics::textures::Texture::getMaxFaceCount ( )
inlinestatic

Return the maximum number of faces that a texture can have.

Bool om::graphics::textures::Texture::isCube ( ) const
inline

Return whether or not this texture is a cube map texture.

Bool om::graphics::textures::Texture::isValidFace ( const TextureFace face) const
inline

Return whether or not the specified face is valid for this texture.

TextureType om::graphics::textures::Texture::getType ( ) const
inline

Return an object describing the high-level type of this texture.

Bool om::graphics::textures::Texture::getFace ( Image *&  image,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
) const
inline

Get the texture's image data for the specified face index with the data in the default pixel type.

If the face type is not equal to TextureFace::FRONT and the texture is not a cube map texture, the method can fail and FALSE is returned. Otherwise, the method succeeds and TRUE is returned.

Bool om::graphics::textures::Texture::getFace ( Image *&  image,
const PixelFormat &  pixelType,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
) const

Get the texture's image data for the specified face index with the data in the specified pixel type.

If the face type is not equal to TextureFace::FRONT and the texture is not a cube map texture, an empty image with UNDEFINED pixel type is returned.

Bool om::graphics::textures::Texture::setFace ( Image *  newImage,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
)

Replace the current contents of the texture with the specified image.

If the image's pixel type is not compatable with the current type of the texture, or if the face index is not equal to TextureFace::FRONT and the texture is not a cube map texture, or if an invalid mipmap level is specified, FALSE is returned indicating failure and the method has no effect. Otherwise, the method succeeds and TRUE is returned.

Bool om::graphics::textures::Texture::updateFace ( const Image &  newImage,
Int  position,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
)
inline

Update a region of the texture with the specified image.

Bool om::graphics::textures::Texture::updateFace ( const Image &  newImage,
const Vector2i position,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
)
inline

Update a region of the texture with the specified image.

Bool om::graphics::textures::Texture::updateFace ( const Image &  newImage,
const Vector3i position,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
)

Update a region of the texture with the specified image.

This method replaces some of the pixels that are currently part of the texture with the pixels stored in the specified image. The texture is replaced with the image starting at the specified position in pixels from its lower left corner.

If the updated pixels will lie outside of the texture's area, or if the image's pixel type is not compatable with the current type of the texture, or if the face index is not equal to TextureFace::FRONT and the texture is not a cube map texture, FALSE is returned indicating failure and the method has no effect. Otherwise, the method succeeds and TRUE is returned.

Bool om::graphics::textures::Texture::clearFace ( Float  channelColor,
TextureFace  face = TextureFace::FRONT,
Index  mipmapLevel = 0 
)

Clear this texture's image using the specified clear color component for the given face and mipmap level.

This method initializes every texel of the texture with the specified color component for every texture component.

The method returns whether or not the clear operation was successful.

TextureWrapType om::graphics::textures::Texture::getWrapType ( ) const

Return the type of texture wrapping to do when texture coordinates are outside of the range [0,1].

void om::graphics::textures::Texture::setWrapType ( const TextureWrapType newWrapType)

Set the type of texture wrapping to do when texture coordinates are outside of the range [0,1].

TextureFilter om::graphics::textures::Texture::getDownsampleFilter ( ) const

Return the type of texture filtering that is used when the texture is reduced in size.

void om::graphics::textures::Texture::setDownsampleFilter ( const TextureFilter newDownsampleFilter)

Set the type of texture filtering that is used when the texture is reduced in size.

TextureFilter om::graphics::textures::Texture::getUpsampleFilter ( ) const

Return the type of texture filtering that is used when the texture is increased in size.

void om::graphics::textures::Texture::setUpsampleFilter ( const TextureFilter newUpsampleFilter)

Set the type of texture filtering that is used when the texture is increased in size.

Size om::graphics::textures::Texture::getMipmapCount ( const TextureFace face = TextureFace::FRONT) const
inline

Return the number of mipmaps that there are for the specified texture face.

This number includes the main mipmap level 0.

Bool om::graphics::textures::Texture::generateMipmaps ( )

Generate smaller mipmaps of the texture from the largest texture image (level 0).

This method automatically scales down the largest mipmap level (level 0) for each of the smaller mipmap levels (>1), replacing any previous mipmap information.

TextureFlags& om::graphics::textures::Texture::getFlags ( )
inline

Return a reference to an object that contains boolean parameters of the texture.

const TextureFlags& om::graphics::textures::Texture::getFlags ( ) const
inline

Return an object that contains boolean parameters of the texture.

void om::graphics::textures::Texture::setFlags ( const TextureFlags newFlags)
inline

Set an object that contains boolean parameters of the texture.

Bool om::graphics::textures::Texture::flagIsSet ( TextureFlags::Flag  flag) const
inline

Return whether or not the specified boolan flag is set for this texture.

void om::graphics::textures::Texture::setFlag ( TextureFlags::Flag  flag,
Bool  newIsSet = true 
)
inline

Set whether or not the specified boolan flag is set for this texture.

virtual void om::graphics::textures::Texture::setContext ( devices::GraphicsContext newContext)
virtual

Set a pointer to the graphics context this texture should use to do rendering.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual void om::graphics::textures::Texture::upload ( UploadRequest request)
virtual

Upload this texture's CPU representation to the GPU device.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual void om::graphics::textures::Texture::download ( DownloadRequest request)
virtual

Download the texture's GPU representation to CPU memory.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Texture::isUploaded ( ) const
virtual

Return whether or not this texture has been successfully created and uploaded to the device.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Texture::isDownloaded ( ) const
virtual

Return whether or not this texture has a copy of its data stored in CPU-side memory.

Reimplemented from om::graphics::devices::GraphicsContextObject.

virtual Bool om::graphics::textures::Texture::isValid ( ) const
virtual

Return whether or not the state of this texture is valid (either on CPU or GPU) and able to be used for rendering.

Reimplemented from om::graphics::devices::GraphicsContextObject.

const DeviceTexture* om::graphics::textures::Texture::getRenderable ( ) const
inline

Return a pointer to the context-renderable texture for this texture, or NULL if there is none.

If the texture has a valid context and the the images for this texture have been uploaded to the GPU successfully after a call to upload(), the method returns a pointer to the GPU texture instance for this texture object.

Otherwise, the texture is not renderable and NULL is returned.

const Shared<DeviceTexture>& om::graphics::textures::Texture::getSharedRenderable ( ) const
inline

Return a shared pointer to the context-renderable texture for this texture, or NULL if there is none.

If the texture has a valid context and the the images for this texture have been uploaded to the GPU successfully after a call to upload(), the method returns a pointer to the GPU texture instance for this texture object.

Otherwise, the texture is not renderable and NULL is returned.

Member Data Documentation

const ResourceType om::graphics::textures::Texture::RESOURCE_TYPE
static

The resource type for a graphics texture.


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