Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics
[Home] [Tutorials] [All Classes] [Grouped Classes]
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes

vl::Texture Class Reference

Wraps an OpenGL texture object representing and managing all the supported texture types. More...

#include <Texture.hpp>

Inheritance diagram for vl::Texture:
vl::Object

List of all members.

Classes

class  SetupParams
 The SetupParams function wraps all the parameters needed to crate a Texture. More...

Public Member Functions

virtual const char * className ()
 Returns the name of the class.
 Texture (const String &image_path, ETextureFormat format=TF_RGBA, bool mipmaps=true, bool border=false)
 Constructs a texture from the specified file.
 Texture (Image *image, ETextureFormat format=TF_RGBA, bool mipmaps=true, bool border=false)
 Constructs a texture from the specified image.
 Texture (int width, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 1D texture.
 Texture (int width, int height, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 2D texture.
 Texture (int width, int height, int depth, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 3D texture.
 Texture ()
 Constructs an null texture that can be initialized later using one of the prepareTexture*() functions or calling createTexture().
 ~Texture ()
 Destructor.
TexParametergetTexParameter ()
 The TexParameter object associated to a Texture.
const TexParametergetTexParameter () const
 The TexParameter object associated to a Texture.
bool createTexture ()
 Creates a texture using the parameters specified by the last prepareTexture*() called.
bool createTexture (ETextureDimension tex_dimension, ETextureFormat tex_format, int w, int h, int d, bool border)
 Creates an empty texture, with no mipmaps, of the specified type, format and dimensions.
bool setMipLevel (int mip_level, Image *img, bool gen_mipmaps)
 Copies the texture image to the specified mip-maping level.
void prepareTexture1D (int width, ETextureFormat format, bool border=false)
 Prepares for creation an empty 1D texture.
void prepareTexture1D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 1D texture from the specified file.
void prepareTexture1D (Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 1D texture from the specified image.
void prepareTexture2D (int width, int height, ETextureFormat format, bool border=false)
 Prepares for creation an empty 2D texture.
void prepareTexture2D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 2D texture from the specified file.
void prepareTexture2D (Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 2D texture from the specified image.
void prepareTexture3D (int width, int height, int depth, ETextureFormat format, bool border=false)
 Prepares for creation an empty 3D texture.
void prepareTexture3D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 3D texture from the specified file.
void prepareTexture3D (Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 3D texture from the specified image.
void prepareTextureCubemap (int width, int height, ETextureFormat format, bool border=false)
 Prepares for creation an empty cubemap texture.
void prepareTextureCubemap (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a cubemap texture from the specified file.
void prepareTextureCubemap (Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a cubemap texture from the specified image.
void prepareTexture1DArray (int width, int count, ETextureFormat format)
 Prepares for creation an empty 1D array texture.
void prepareTexture1DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 1d texture array from the specified file.
void prepareTexture1DArray (Image *image, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 1d texture array from the specified image.
void prepareTexture2DArray (int width, int height, int count, ETextureFormat format)
 Prepares for creation an empty 2D array texture.
void prepareTexture2DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 2d texture array from the specified file.
void prepareTexture2DArray (Image *image, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 2d texture array from the specified image.
void prepareTextureRectangle (int width, int height, ETextureFormat format)
 Prepares for creation an empty texture rectangle.
void prepareTextureRectangle (const String &image_path, ETextureFormat format)
 Prepares for creation a texture rectangle from the specified file.
void prepareTextureRectangle (Image *image, ETextureFormat format)
 Prepares for creation a texture rectangle from the specified image.
bool isValid () const
 Returns true if the current texture configuration seems valid.
unsigned int handle () const
 OpenGL texture handle as returned by glGenTextures().
void setHandle (unsigned int id)
 OpenGL texture handle as returned by glGenTextures().
void setDimension (ETextureDimension dimension)
 The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
ETextureDimension dimension () const
 The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().
void setInternalFormat (ETextureFormat format)
 The texture internal format as pecified by the internalFormat parameter of glTexImage*().
ETextureFormat internalFormat () const
 The texture internal format as pecified by the internalFormat parameter of glTexImage*().
void setWidth (int x)
 The horizontal dimension of the texture in texels.
int width () const
 The horizontal dimension of the texture in texels.
void setHeight (int y)
 The vertical dimension of the texture in texels.
int height () const
 The vertical dimension of the texture in texels.
void setDepth (int z)
 The z dimension of the texture in texels.
int depth () const
 The z dimension of the texture in texels.
void setBorder (bool border)
 Whether the texture has a 1 pixel texture border or not.
bool border () const
 Whether the texture has a 1 pixel texture border or not.
const SetupParamssetupParams () const
 See SetupParams.
SetupParamssetupParams ()
 See SetupParams.
void setSetupParams (SetupParams *setup_params)
 See SetupParams.

Static Public Member Functions

static bool supports (ETextureDimension tex_dimension, ETextureFormat tex_format, int mip_level, EImageDimension img_dimension, int w, int h, int d, bool border, bool verbose)
 Checks whether the specified texture type, format and dimension combination is supported by the current OpenGL driver.
static bool isCompressedFormat (int format)
 Returns true if the specified format is compressed.

Protected Attributes

unsigned int mHandle
TexParameter mTexParameter
ref< SetupParamsmSetupParams
ETextureFormat mFormat
ETextureDimension mDimension
int mWidth
int mHeight
int mDepth
bool mBorder

Detailed Description

Wraps an OpenGL texture object representing and managing all the supported texture types.

Remarks:
Many of the parameters used to create a Textures are the same used by glTexImage1D/2D/3D etc. See the following for more information:
Note:
A TexParameter defines a set of variables associated to a Texture while TexGen and TexEnv define a set of variables associated to a TextureUnit.
See also:

Constructor & Destructor Documentation

Texture::Texture ( const String image_path,
ETextureFormat  format = TF_RGBA,
bool  mipmaps = true,
bool  border = false 
)

Constructs a texture from the specified file.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this constructor.
Texture::Texture ( Image image,
ETextureFormat  format = TF_RGBA,
bool  mipmaps = true,
bool  border = false 
)

Constructs a texture from the specified image.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this constructor.
Texture::Texture ( int  width,
ETextureFormat  format = TF_RGBA,
bool  border = false 
)

Constructs an empty 1D texture.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this constructor.
Texture::Texture ( int  width,
int  height,
ETextureFormat  format = TF_RGBA,
bool  border = false 
)

Constructs an empty 2D texture.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this constructor.
Texture::Texture ( int  width,
int  height,
int  depth,
ETextureFormat  format = TF_RGBA,
bool  border = false 
)

Constructs an empty 3D texture.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this constructor.
Texture::Texture (  )

Constructs an null texture that can be initialized later using one of the prepareTexture*() functions or calling createTexture().

Texture::~Texture (  )

Destructor.


Member Function Documentation

virtual const char* vl::Texture::className (  ) [inline, virtual]

Returns the name of the class.

Reimplemented from vl::Object.

TexParameter* vl::Texture::getTexParameter (  ) [inline]

The TexParameter object associated to a Texture.

const TexParameter* vl::Texture::getTexParameter (  ) const [inline]

The TexParameter object associated to a Texture.

bool Texture::createTexture (  )

Creates a texture using the parameters specified by the last prepareTexture*() called.

Remarks:
You can retrieve the currently active texture creation settings using the setupParams() function.
Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this function.
bool Texture::createTexture ( ETextureDimension  tex_dimension,
ETextureFormat  tex_format,
int  w,
int  h,
int  d,
bool  border 
)

Creates an empty texture, with no mipmaps, of the specified type, format and dimensions.

Note:
The OpenGL texture object is created immediately therefore an OpenGL context must be active when calling this function.
bool Texture::setMipLevel ( int  mip_level,
Image img,
bool  gen_mipmaps 
)

Copies the texture image to the specified mip-maping level.

This function can be useful to specify one by one the mipmapping images or to create texture animation effects. mip_level The mip-mapping level to be modified. img The Image containing the pixels to be copied into the specified mip-mapping level. gen_mipmaps If true automatically generates the mip-mapping images for the levels below mip_level.

Remarks:
Before calling this function one of the two createTexture() methods must have been called.
Note:
The mip-map level is updated immediately therefore an OpenGL context must be active when calling this function.
void vl::Texture::prepareTexture1D ( int  width,
ETextureFormat  format,
bool  border = false 
) [inline]

Prepares for creation an empty 1D texture.

void vl::Texture::prepareTexture1D ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 1D texture from the specified file.

void vl::Texture::prepareTexture1D ( Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 1D texture from the specified image.

void vl::Texture::prepareTexture2D ( int  width,
int  height,
ETextureFormat  format,
bool  border = false 
) [inline]

Prepares for creation an empty 2D texture.

void vl::Texture::prepareTexture2D ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 2D texture from the specified file.

void vl::Texture::prepareTexture2D ( Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 2D texture from the specified image.

void vl::Texture::prepareTexture3D ( int  width,
int  height,
int  depth,
ETextureFormat  format,
bool  border = false 
) [inline]

Prepares for creation an empty 3D texture.

void vl::Texture::prepareTexture3D ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 3D texture from the specified file.

void vl::Texture::prepareTexture3D ( Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a 3D texture from the specified image.

void vl::Texture::prepareTextureCubemap ( int  width,
int  height,
ETextureFormat  format,
bool  border = false 
) [inline]

Prepares for creation an empty cubemap texture.

void vl::Texture::prepareTextureCubemap ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a cubemap texture from the specified file.

void vl::Texture::prepareTextureCubemap ( Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
) [inline]

Prepares for creation a cubemap texture from the specified image.

void vl::Texture::prepareTexture1DArray ( int  width,
int  count,
ETextureFormat  format 
) [inline]

Prepares for creation an empty 1D array texture.

void vl::Texture::prepareTexture1DArray ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true 
) [inline]

Prepares for creation a 1d texture array from the specified file.

void vl::Texture::prepareTexture1DArray ( Image image,
ETextureFormat  format,
bool  mipmaps = true 
) [inline]

Prepares for creation a 1d texture array from the specified image.

void vl::Texture::prepareTexture2DArray ( int  width,
int  height,
int  count,
ETextureFormat  format 
) [inline]

Prepares for creation an empty 2D array texture.

void vl::Texture::prepareTexture2DArray ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true 
) [inline]

Prepares for creation a 2d texture array from the specified file.

void vl::Texture::prepareTexture2DArray ( Image image,
ETextureFormat  format,
bool  mipmaps = true 
) [inline]

Prepares for creation a 2d texture array from the specified image.

void vl::Texture::prepareTextureRectangle ( int  width,
int  height,
ETextureFormat  format 
) [inline]

Prepares for creation an empty texture rectangle.

void vl::Texture::prepareTextureRectangle ( const String image_path,
ETextureFormat  format 
) [inline]

Prepares for creation a texture rectangle from the specified file.

void vl::Texture::prepareTextureRectangle ( Image image,
ETextureFormat  format 
) [inline]

Prepares for creation a texture rectangle from the specified image.

bool Texture::isValid (  ) const

Returns true if the current texture configuration seems valid.

unsigned int vl::Texture::handle (  ) const [inline]

OpenGL texture handle as returned by glGenTextures().

void vl::Texture::setHandle ( unsigned int  id ) [inline]

OpenGL texture handle as returned by glGenTextures().

void vl::Texture::setDimension ( ETextureDimension  dimension ) [inline]

The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().

ETextureDimension vl::Texture::dimension (  ) const [inline]

The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*().

void vl::Texture::setInternalFormat ( ETextureFormat  format ) [inline]

The texture internal format as pecified by the internalFormat parameter of glTexImage*().

ETextureFormat vl::Texture::internalFormat (  ) const [inline]

The texture internal format as pecified by the internalFormat parameter of glTexImage*().

void vl::Texture::setWidth ( int  x ) [inline]

The horizontal dimension of the texture in texels.

int vl::Texture::width (  ) const [inline]

The horizontal dimension of the texture in texels.

void vl::Texture::setHeight ( int  y ) [inline]

The vertical dimension of the texture in texels.

int vl::Texture::height (  ) const [inline]

The vertical dimension of the texture in texels.

void vl::Texture::setDepth ( int  z ) [inline]

The z dimension of the texture in texels.

int vl::Texture::depth (  ) const [inline]

The z dimension of the texture in texels.

void vl::Texture::setBorder ( bool  border ) [inline]

Whether the texture has a 1 pixel texture border or not.

bool vl::Texture::border (  ) const [inline]

Whether the texture has a 1 pixel texture border or not.

const SetupParams* vl::Texture::setupParams (  ) const [inline]
SetupParams* vl::Texture::setupParams (  ) [inline]
void vl::Texture::setSetupParams ( SetupParams setup_params ) [inline]
bool Texture::supports ( ETextureDimension  tex_dimension,
ETextureFormat  tex_format,
int  mip_level,
EImageDimension  img_dimension,
int  w,
int  h,
int  d,
bool  border,
bool  verbose 
) [static]

Checks whether the specified texture type, format and dimension combination is supported by the current OpenGL driver.

bool Texture::isCompressedFormat ( int  format ) [static]

Returns true if the specified format is compressed.


Member Data Documentation

unsigned int vl::Texture::mHandle [protected]
int vl::Texture::mWidth [protected]
int vl::Texture::mHeight [protected]
int vl::Texture::mDepth [protected]
bool vl::Texture::mBorder [protected]

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

Visualization Library v2010.11.1125 Reference Documentation
Copyright 2005-2009 Michele Bosi. All rights reserved.
Updated on Fri Nov 26 2010 10:33:53.
Permission is granted to use this page to write and publish articles regarding Visualization Library.