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

nvsg::Texture Class Reference

Class to hold a texture. More...

#include <Texture.h>

Inheritance diagram for nvsg::Texture:

Inheritance graph
[legend]
Collaboration diagram for nvsg::Texture:

Collaboration graph
[legend]
List of all members.

Public Types

enum  eTexFileType {
  TFT_UNKNOWN = -1, TFT_DDS, TFT_JPG, TFT_TGA,
  TFT_BMP, TFT_TIF, TFT_RGB, TFT_GIF,
  TFT_PNG, TFT_HDR
}
 Enumeration of the supported texture file formats. More...

Public Member Functions

NVSG_API int getComponents (unsigned int image=0, unsigned int mipmap=0) const
 Get the components of the mipmap level of an image of the texture.
NVSG_API int getType (unsigned int image=0, unsigned int mipmap=0) const
 Get the type of the mipmap level of an image of the texture.
NVSG_API int getDepth (unsigned int image=0, unsigned int mipmap=0) const
 Get the depth of the mipmap level of an image of the texture.
NVSG_API int getFormat (unsigned int image=0, unsigned int mipmap=0) const
 Get the format of the mipmap level of an image of the texture.
std::string getFileName (void) const
 Get the filename of the texture.
unsigned int getHandle (void) const
 Get the handle of the texture.
NVSG_API int getHeight (unsigned int image=0, unsigned int mipmap=0) const
 Get the height of the mipmap level of an image of the texture.
unsigned int getNumberOfImages (void) const
 Get the number of image in this texture.
NVSG_API unsigned int getNumberOfMipmaps (unsigned int image=0) const
 Get the number of mipmaps of an image of the texture.
NVSG_API const void * getPixels (unsigned int image=0, unsigned int mipmap=0) const
 Get pointer to pixels of the mipmap level of an image of the texture.
NVSG_API int getSize (unsigned int image=0, unsigned int mipmap=0) const
 Get the size of the mipmap level of an image of the texture.
NVSG_API unsigned long getTarget (void) const
 Get the target of the texture.
NVSG_API int getWidth (unsigned int image=0, unsigned int mipmap=0) const
 Get the width of the mipmap-level of an image of the texture.
NVSG_API bool isCubeMap (void) const
 Ask if this texture is a cubemap.
NVSG_API bool isFloatingPoint (void) const
 Ask if this texture is a floating point texture (4 bpp per color channel).
NVSG_API bool isTexFileType (eTexFileType tft) const
 Ask if this texture is of a specific file type.
NVSG_API bool load (void) const
 Load the texture.
NVSG_API void scale (unsigned int image=0, unsigned int width=128, unsigned int height=128, unsigned int depth=1) const
 Scale an image of the texture to the specified size.
NVSG_API void setHandle (unsigned int handle) const
 Set the handle of the texture.
NVSG_API void setTarget (unsigned long target) const
 Set the target of the texture.
NVSG_API void unload (void) const
 Unload the texture.

Static Public Member Functions

static NVSG_API const Texturecreate (const std::string &fileName, bool flipImage=true)
 Create a Texture out of a file.

Protected Member Functions

NVSG_API Texture (const std::string &fileName, bool flipImage=true)
 Constructor.
virtual NVSG_API ~Texture (void)
 Prohibit explicit creation on stack by making the destructor protected.

Protected Attributes

bool m_cube
 true for cube maps
std::string m_fileName
 file name of the texture
bool m_flipImage
 true for horizontally flipped images
unsigned int m_handle
 opaque handle of the texture
unsigned int m_imageID
 image id of the texture
unsigned int m_numImages
 number of images in the texture
unsigned long m_target
 target type of the texture (GL_TEXTURE_1D,...)
eTexFileType m_texFileType
 texture file type, like TFT_DDS, TFT_JPG (see eTexFileType)

Detailed Description

Class to hold a texture.

This class is used to represent a texture of any format in the scenegraph. It is defined by the filename and hides all the format specific information behind this common interface.

A Texture might contain several images (for example a texture can be a cube map, consisting of six images). Each image might be mipmapped.


Member Enumeration Documentation

enum nvsg::Texture::eTexFileType
 

Enumeration of the supported texture file formats.

Enumeration values:
TFT_UNKNOWN  Unknown format.
TFT_DDS  DDS format.
TFT_JPG  JPG format.
TFT_TGA  TGA format.
TFT_BMP  BMP format.
TFT_TIF  TIF format.
TFT_RGB  RGB format.
TFT_GIF  GIF format.
TFT_PNG  PNG format.
TFT_HDR  HDR format.


Constructor & Destructor Documentation

NVSG_API nvsg::Texture::Texture const std::string &  fileName,
bool  flipImage = true
[protected]
 

Constructor.

Creates a texture out of the file fileName. If requested, it flips the image horizontally.

virtual NVSG_API nvsg::Texture::~Texture void   )  [protected, virtual]
 

Prohibit explicit creation on stack by making the destructor protected.


Member Function Documentation

static NVSG_API const Texture* nvsg::Texture::create const std::string &  fileName,
bool  flipImage = true
[static]
 

Create a Texture out of a file.

Parameters:
fileName  file name of texture
flipImage  flip image horizontally if true

NVSG_API int nvsg::Texture::getComponents unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the components of the mipmap level of an image of the texture.

Returns:
The bytes per pixel of this image
Parameters:
image  image to get bpp from
mipmap  mipmap to get bpp from

NVSG_API int nvsg::Texture::getType unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the type of the mipmap level of an image of the texture.

Returns:
The data type of this image
Parameters:
image  image to get bpp from
mipmap  mipmap to get bpp from

NVSG_API int nvsg::Texture::getDepth unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the depth of the mipmap level of an image of the texture.

Returns:
The depth, if it is a 3D-texture, otherwise 1
Parameters:
image  image to get depth from
mipmap  mipmap to get depth from

NVSG_API int nvsg::Texture::getFormat unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the format of the mipmap level of an image of the texture.

Returns:
The format of the texture (equals GL-format like GL_RGBA)
Parameters:
image  image to get format from
mipmap  mipmap to get format from

std::string nvsg::Texture::getFileName void   )  const [inline]
 

Get the filename of the texture.

Returns:
The filename of the texture

unsigned int nvsg::Texture::getHandle void   )  const [inline]
 

Get the handle of the texture.

Each texture can have an associated handle that can be queried here.

Returns:
The texture handle of the texture

NVSG_API int nvsg::Texture::getHeight unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the height of the mipmap level of an image of the texture.

Returns:
The height of the mipmap level of this image
Parameters:
image  image to get height from
mipmap  mipmap to get height from

unsigned int nvsg::Texture::getNumberOfImages void   )  const [inline]
 

Get the number of image in this texture.

Returns:
The number of images in the texture (e.g. 6 for a cubemap)

NVSG_API unsigned int nvsg::Texture::getNumberOfMipmaps unsigned int  image = 0  )  const
 

Get the number of mipmaps of an image of the texture.

Returns:
The number of mipmaps of image
Parameters:
image  image to get information from

NVSG_API const void* nvsg::Texture::getPixels unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get pointer to pixels of the mipmap level of an image of the texture.

Returns:
A constant pointer to image data
Parameters:
image  image to get data from
mipmap  mipmap to get data from

NVSG_API int nvsg::Texture::getSize unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the size of the mipmap level of an image of the texture.

Returns:
The size of the image data mipmap level
Parameters:
image  image to get image size from
mipmap  mipmap to get image size from

unsigned long nvsg::Texture::getTarget void   )  const [inline]
 

Get the target of the texture.

The target is an arbitrary ID that can be used to classify this texture.

Returns:
The target of the texture

NVSG_API int nvsg::Texture::getWidth unsigned int  image = 0,
unsigned int  mipmap = 0
const
 

Get the width of the mipmap-level of an image of the texture.

Returns:
The width of the mipmap-level of this image
Parameters:
image  image to get width from
mipmap  mipmap to get width from

bool nvsg::Texture::isCubeMap void   )  const [inline]
 

Ask if this texture is a cubemap.

Returns:
true, if this texture is a cubemap, otherwise false

NVSG_API bool nvsg::Texture::isFloatingPoint void   )  const
 

Ask if this texture is a floating point texture (4 bpp per color channel).

Returns:
true, if this texture is a floating point texture, otherwise false

bool nvsg::Texture::isTexFileType eTexFileType  tft  )  const [inline]
 

Ask if this texture is of a specific file type.

Returns:
true, if the file type is tft, otherwise false
Parameters:
tft  texture file type to test for

NVSG_API bool nvsg::Texture::load void   )  const
 

Load the texture.

Returns:
true, if the texture was successfully loaded, otherwise false

NVSG_API void nvsg::Texture::scale unsigned int  image = 0,
unsigned int  width = 128,
unsigned int  height = 128,
unsigned int  depth = 1
const
 

Scale an image of the texture to the specified size.

Parameters:
image  The image to scale - 2D textures conatain one image, so 0 is a reasonable value;
Cube maps contain 6 images so the index runs from 0-4
width  The width to achieve
height  The height to achieve
depth  The depth to achieve - only usefull for 3D textures.

void nvsg::Texture::setHandle unsigned int  handle  )  const [inline]
 

Set the handle of the texture.

Parameters:
handle  handle to use with this Texture

void nvsg::Texture::setTarget unsigned long  target  )  const [inline]
 

Set the target of the texture.

The target is an arbitrary ID that can be used to classify this texture.

Parameters:
target  target for this texture

NVSG_API void nvsg::Texture::unload void   )  const
 

Unload the texture.


Member Data Documentation

bool nvsg::Texture::m_cube [mutable, protected]
 

true for cube maps

std::string nvsg::Texture::m_fileName [protected]
 

file name of the texture

bool nvsg::Texture::m_flipImage [protected]
 

true for horizontally flipped images

unsigned int nvsg::Texture::m_handle [mutable, protected]
 

opaque handle of the texture

unsigned int nvsg::Texture::m_imageID [mutable, protected]
 

image id of the texture

unsigned int nvsg::Texture::m_numImages [mutable, protected]
 

number of images in the texture

unsigned long nvsg::Texture::m_target [mutable, protected]
 

target type of the texture (GL_TEXTURE_1D,...)

eTexFileType nvsg::Texture::m_texFileType [mutable, protected]
 

texture file type, like TFT_DDS, TFT_JPG (see eTexFileType)


The documentation for this class was generated from the following file:
Generated on Tue Mar 1 13:20:58 2005 for NVSGSDK by NVIDIA