Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
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:

Classes

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

Public Member Functions

 Texture (const String &image_path, ETextureFormat format=TF_RGBA, bool mipmaps=true, bool border=false)
 Constructs a 1D, 2D, 3D or Cubemap texture from the specified file. More...
 
 Texture (const Image *image, ETextureFormat format=TF_RGBA, bool mipmaps=true, bool border=false)
 Constructs a 1D, 2D, 3D or Cubemap texture from the specified image. More...
 
 Texture (int width, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 1D texture. More...
 
 Texture (int width, int height, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 2D texture. More...
 
 Texture (int width, int height, int depth, ETextureFormat format=TF_RGBA, bool border=false)
 Constructs an empty 3D texture. More...
 
 Texture ()
 Constructs an null texture that can be initialized later using one of the prepareTexture*() functions or calling createTexture(). More...
 
 ~Texture ()
 Destructor. More...
 
TexParametergetTexParameter ()
 The TexParameter object associated to a Texture. More...
 
const TexParametergetTexParameter () const
 The TexParameter object associated to a Texture. More...
 
const TexParametergetTexParameterOverride () const
 The TexParameter belonging to a TextureSampler that is currently overriding the Texture's own TexParameter. More...
 
BufferObjectbufferObject ()
 The buffer object bound to a buffer object texture. More...
 
const BufferObjectbufferObject () const
 The buffer object bound to a buffer object texture. More...
 
void destroyTexture ()
 Destroys the GL texture object if managed() is true (default). More...
 
bool createTexture ()
 Creates a texture using the parameters specified by the last prepareTexture*() called. More...
 
bool createTexture (ETextureDimension tex_dimension, ETextureFormat tex_format, int w, int h, int d, bool border, BufferObject *bo, int samples, bool fixedsamplelocations)
 Creates an empty texture, with no mipmaps, of the specified type, format and dimensions. More...
 
bool setMipLevel (int mip_level, const Image *img, bool gen_mipmaps)
 Copies the texture image to the specified mip-maping level. More...
 
void prepareTexture1D (int width, ETextureFormat format, bool border=false)
 Prepares for creation an empty 1D texture. More...
 
bool createTexture1D (int width, ETextureFormat format, bool border=false)
 Creates an empty 1D texture. More...
 
void prepareTexture1D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 1D texture from the specified file. More...
 
bool createTexture1D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 1D texture from the specified file. More...
 
void prepareTexture1D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 1D texture from the specified image. More...
 
bool createTexture1D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 1D texture from the specified image. More...
 
void prepareTexture2D (int width, int height, ETextureFormat format, bool border=false)
 Prepares for creation an empty 2D texture. More...
 
bool createTexture2D (int width, int height, ETextureFormat format, bool border=false)
 Creates an empty 2D texture. More...
 
void prepareTexture2D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 2D texture from the specified file. More...
 
bool createTexture2D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 2D texture from the specified file. More...
 
void prepareTexture2D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 2D texture from the specified image. More...
 
bool createTexture2D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 2D texture from the specified image. More...
 
void prepareTexture3D (int width, int height, int depth, ETextureFormat format, bool border=false)
 Prepares for creation an empty 3D texture. More...
 
bool createTexture3D (int width, int height, int depth, ETextureFormat format, bool border=false)
 Creates an empty 3D texture. More...
 
void prepareTexture3D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 3D texture from the specified file. More...
 
bool createTexture3D (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 3D texture from the specified file. More...
 
void prepareTexture3D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a 3D texture from the specified image. More...
 
bool createTexture3D (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a 3D texture from the specified image. More...
 
void prepareTextureCubemap (int width, int height, ETextureFormat format, bool border=false)
 Prepares for creation an empty cubemap texture. More...
 
bool createTextureCubemap (int width, int height, ETextureFormat format, bool border=false)
 Creates an empty cubemap texture. More...
 
void prepareTextureCubemap (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a cubemap texture from the specified file. More...
 
bool createTextureCubemap (const String &image_path, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates creation a cubemap texture from the specified file. More...
 
void prepareTextureCubemap (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Prepares for creation a cubemap texture from the specified image. More...
 
bool createTextureCubemap (const Image *image, ETextureFormat format, bool mipmaps=true, bool border=false)
 Creates a cubemap texture from the specified image. More...
 
void prepareTexture1DArray (int width, int count, ETextureFormat format)
 Prepares for creation an empty 1D array texture. More...
 
bool createTexture1DArray (int width, int count, ETextureFormat format)
 Creates an empty 1D array texture. More...
 
void prepareTexture1DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 1d texture array from the specified file. More...
 
bool createTexture1DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Creates a 1d texture array from the specified file. More...
 
void prepareTexture1DArray (const Image *image, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 1d texture array from the specified image. More...
 
bool createTexture1DArray (const Image *image, ETextureFormat format, bool mipmaps=true)
 Creates a 1d texture array from the specified image. More...
 
void prepareTexture2DArray (int width, int height, int count, ETextureFormat format)
 Prepares for creation an empty 2D array texture. More...
 
bool createTexture2DArray (int width, int height, int count, ETextureFormat format)
 Creates an empty 2D array texture. More...
 
void prepareTexture2DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 2d texture array from the specified file. More...
 
bool createTexture2DArray (const String &image_path, ETextureFormat format, bool mipmaps=true)
 Creates a 2d texture array from the specified file. More...
 
void prepareTexture2DArray (const Image *image, ETextureFormat format, bool mipmaps=true)
 Prepares for creation a 2d texture array from the specified image. More...
 
bool createTexture2DArray (const Image *image, ETextureFormat format, bool mipmaps=true)
 Creates a 2d texture array from the specified image. More...
 
void prepareTextureRectangle (int width, int height, ETextureFormat format)
 Prepares for creation an empty texture rectangle. More...
 
bool createTextureRectangle (int width, int height, ETextureFormat format)
 Creates an empty texture rectangle. More...
 
void prepareTextureRectangle (const String &image_path, ETextureFormat format)
 Prepares for creation a texture rectangle from the specified file. More...
 
bool createTextureRectangle (const String &image_path, ETextureFormat format)
 Creates a texture rectangle from the specified file. More...
 
void prepareTextureRectangle (const Image *image, ETextureFormat format)
 Prepares for creation a texture rectangle from the specified image. More...
 
bool createTextureRectangle (const Image *image, ETextureFormat format)
 Creates a texture rectangle from the specified image. More...
 
void prepareTextureBuffer (vl::ETextureFormat format, BufferObject *bo)
 Prepares a texture buffer texture. More...
 
bool createTextureBuffer (vl::ETextureFormat format, BufferObject *bo)
 Creates a texture buffer texture. More...
 
void prepareTexture2DMultisample (int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
 Prepares a 2D multisample texture. More...
 
bool createTexture2DMultisample (int width, int height, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
 Creates a 2D multisample texture. More...
 
void prepareTexture2DMultisampleArray (int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
 Prepares a 3D multisample texture. More...
 
bool createTexture2DMultisampleArray (int width, int height, int depth, vl::ETextureFormat format, int samples, bool fixedsamplelocations)
 Creates a 3D multisample texture. More...
 
void setHandle (unsigned int id, bool managed=true)
 OpenGL texture handle as returned by glGenTextures(). More...
 
unsigned int handle () const
 OpenGL texture handle as returned by glGenTextures(). More...
 
void setManaged (bool managed)
 If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or destroyTexture() is called. More...
 
bool managed () const
 If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or destroyTexture() is called. More...
 
void setDimension (ETextureDimension dimension)
 The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*(). More...
 
ETextureDimension dimension () const
 The texture type (1d, 2d, cubemap etc.) as specified by the target parameter of glTexImage*(). More...
 
void setInternalFormat (ETextureFormat format)
 The texture internal format as pecified by the internalFormat parameter of glTexImage*(). More...
 
ETextureFormat internalFormat () const
 The texture internal format as pecified by the internalFormat parameter of glTexImage*(). More...
 
void setWidth (int x)
 The horizontal dimension of the texture in texels. More...
 
int width () const
 The horizontal dimension of the texture in texels. More...
 
void setHeight (int y)
 The vertical dimension of the texture in texels. More...
 
int height () const
 The vertical dimension of the texture in texels. More...
 
void setDepth (int z)
 The z dimension of the texture in texels. More...
 
int depth () const
 The z dimension of the texture in texels. More...
 
void setBorder (bool border)
 Whether the texture has a 1 pixel texture border or not. More...
 
bool border () const
 Whether the texture has a 1 pixel texture border or not. More...
 
void setSamples (int samples)
 The number of samples of a multisample texture. More...
 
int samples () const
 The number of samples of a multisample texture. More...
 
void setFixedSamplesLocation (bool fixed)
 Whether the samples location is fixed for a a multisample texture. More...
 
bool fixedSamplesLocation () const
 Whether the samples location is fixed for a a multisample texture. More...
 
void setSetupParams (SetupParams *setup_params)
 See SetupParams. More...
 
const SetupParamssetupParams () const
 See SetupParams. More...
 
SetupParamssetupParams ()
 See SetupParams. More...
 
bool isValid () const
 Returns true if the current texture configuration seems valid. More...
 
bool isDepthTexture () const
 Returns true if the texture is a depth or depth/stencil textre. More...
 
void clone (const Texture &other)
 Copies all the texture parameters form the specified texture, including the OpenGL texture handle. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

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, int samples, bool fixedsamplelocations, bool verbose)
 Checks whether the specified texture type, format and dimension combination is supported by the current OpenGL driver. More...
 
static bool isCompressedFormat (int format)
 Returns true if the specified format is compressed. More...
 

Protected Attributes

unsigned int mHandle
 
bool mManaged
 
ref< TexParametermTexParameter
 
ref< TexParametermTexParameterOverride
 
ref< SetupParamsmSetupParams
 
ref< BufferObjectmBufferObject
 
ETextureFormat mFormat
 
ETextureDimension mDimension
 
int mWidth
 
int mHeight
 
int mDepth
 
int mSamples
 
bool mBorder
 
bool mFixedSamplesLocation
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Friends

class TextureSampler
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

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 TextureSampler.
See also

Definition at line 143 of file Texture.hpp.

Constructor & Destructor Documentation

◆ Texture() [1/6]

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

Constructs a 1D, 2D, 3D or Cubemap texture from the specified file.

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

Definition at line 453 of file Texture.cpp.

References border(), vl::Log::bug(), createTexture(), vl::Image::dimension(), vl::Log::error(), vl::ref< T >::get(), vl::ID_1D, vl::ID_2D, vl::ID_3D, vl::ID_Cubemap, vl::Image::isValid(), vl::loadImage(), mTexParameter, prepareTexture1D(), prepareTexture2D(), prepareTexture3D(), and prepareTextureCubemap().

◆ Texture() [2/6]

Texture::Texture ( const Image image,
ETextureFormat  format = TF_RGBA,
bool  mipmaps = true,
bool  border = false 
)

Constructs a 1D, 2D, 3D or Cubemap texture from the specified image.

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

Definition at line 425 of file Texture.cpp.

References vl::Log::bug(), createTexture(), vl::Image::dimension(), vl::Log::error(), vl::ID_1D, vl::ID_2D, vl::ID_3D, vl::ID_Cubemap, vl::Image::isValid(), mTexParameter, prepareTexture1D(), prepareTexture2D(), prepareTexture3D(), and prepareTextureCubemap().

◆ Texture() [3/6]

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.

Definition at line 392 of file Texture.cpp.

References createTexture(), vl::Log::error(), mTexParameter, NULL, and vl::TD_TEXTURE_1D.

◆ Texture() [4/6]

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.

Definition at line 403 of file Texture.cpp.

References createTexture(), vl::Log::error(), mTexParameter, NULL, and vl::TD_TEXTURE_2D.

◆ Texture() [5/6]

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.

Definition at line 414 of file Texture.cpp.

References createTexture(), vl::Log::error(), mTexParameter, NULL, and vl::TD_TEXTURE_3D.

◆ Texture() [6/6]

Texture::Texture ( )

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

Definition at line 483 of file Texture.cpp.

References mTexParameter.

◆ ~Texture()

Texture::~Texture ( )

Member Function Documentation

◆ border()

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

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

Definition at line 715 of file Texture.hpp.

Referenced by createTexture(), setMipLevel(), and Texture().

◆ bufferObject() [1/2]

BufferObject* vl::Texture::bufferObject ( )
inline

The buffer object bound to a buffer object texture.

Definition at line 255 of file Texture.hpp.

Referenced by createTexture().

◆ bufferObject() [2/2]

const BufferObject* vl::Texture::bufferObject ( ) const
inline

The buffer object bound to a buffer object texture.

Definition at line 258 of file Texture.hpp.

◆ clone()

void Texture::clone ( const Texture other)

Copies all the texture parameters form the specified texture, including the OpenGL texture handle.

Mainly useful when you want to use the same texture object with different texture parameters.

Definition at line 1191 of file Texture.cpp.

References mBorder, mBufferObject, mDepth, mDimension, mFixedSamplesLocation, mFormat, mHandle, mHeight, mSamples, mSetupParams, mTexParameter, mWidth, and NULL.

◆ createTexture() [1/2]

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.

Definition at line 1083 of file Texture.cpp.

References vl::Texture::SetupParams::border(), border(), bufferObject(), vl::Texture::SetupParams::depth(), vl::Texture::SetupParams::dimension(), vl::Log::error(), vl::Texture::SetupParams::format(), vl::Texture::SetupParams::genMipmaps(), vl::Texture::SetupParams::height(), vl::Texture::SetupParams::image(), vl::loadImage(), mSetupParams, NULL, samples(), vl::Texture::SetupParams::setImage(), setMipLevel(), vl::Object::setObjectName(), setupParams(), vl::TF_UNKNOWN, VL_CHECK, VL_CHECK_OGL, and vl::Texture::SetupParams::width().

Referenced by vl::Rendering::fillRenderQueue(), and Texture().

◆ createTexture() [2/2]

bool Texture::createTexture ( ETextureDimension  tex_dimension,
ETextureFormat  tex_format,
int  w,
int  h,
int  d,
bool  border,
BufferObject bo,
int  samples,
bool  fixedsamplelocations 
)

◆ createTexture1D() [1/3]

bool vl::Texture::createTexture1D ( int  width,
ETextureFormat  format,
bool  border = false 
)
inline

Creates an empty 1D texture.

Definition at line 290 of file Texture.hpp.

◆ createTexture1D() [2/3]

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

Creates a 1D texture from the specified file.

Definition at line 304 of file Texture.hpp.

◆ createTexture1D() [3/3]

bool vl::Texture::createTexture1D ( const Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
)
inline

Creates a 1D texture from the specified image.

Definition at line 322 of file Texture.hpp.

◆ createTexture1DArray() [1/3]

bool vl::Texture::createTexture1DArray ( int  width,
int  count,
ETextureFormat  format 
)
inline

Creates an empty 1D array texture.

Definition at line 479 of file Texture.hpp.

◆ createTexture1DArray() [2/3]

bool vl::Texture::createTexture1DArray ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true 
)
inline

Creates a 1d texture array from the specified file.

Definition at line 493 of file Texture.hpp.

◆ createTexture1DArray() [3/3]

bool vl::Texture::createTexture1DArray ( const Image image,
ETextureFormat  format,
bool  mipmaps = true 
)
inline

Creates a 1d texture array from the specified image.

Definition at line 511 of file Texture.hpp.

◆ createTexture2D() [1/3]

bool vl::Texture::createTexture2D ( int  width,
int  height,
ETextureFormat  format,
bool  border = false 
)
inline

Creates an empty 2D texture.

Definition at line 337 of file Texture.hpp.

◆ createTexture2D() [2/3]

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

Creates a 2D texture from the specified file.

Definition at line 351 of file Texture.hpp.

◆ createTexture2D() [3/3]

bool vl::Texture::createTexture2D ( const Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
)
inline

Creates a 2D texture from the specified image.

Definition at line 369 of file Texture.hpp.

◆ createTexture2DArray() [1/3]

bool vl::Texture::createTexture2DArray ( int  width,
int  height,
int  count,
ETextureFormat  format 
)
inline

Creates an empty 2D array texture.

Definition at line 527 of file Texture.hpp.

◆ createTexture2DArray() [2/3]

bool vl::Texture::createTexture2DArray ( const String image_path,
ETextureFormat  format,
bool  mipmaps = true 
)
inline

Creates a 2d texture array from the specified file.

Definition at line 541 of file Texture.hpp.

◆ createTexture2DArray() [3/3]

bool vl::Texture::createTexture2DArray ( const Image image,
ETextureFormat  format,
bool  mipmaps = true 
)
inline

Creates a 2d texture array from the specified image.

Definition at line 559 of file Texture.hpp.

◆ createTexture2DMultisample()

bool vl::Texture::createTexture2DMultisample ( int  width,
int  height,
vl::ETextureFormat  format,
int  samples,
bool  fixedsamplelocations 
)
inline

Creates a 2D multisample texture.

Definition at line 645 of file Texture.hpp.

◆ createTexture2DMultisampleArray()

bool vl::Texture::createTexture2DMultisampleArray ( int  width,
int  height,
int  depth,
vl::ETextureFormat  format,
int  samples,
bool  fixedsamplelocations 
)
inline

Creates a 3D multisample texture.

Definition at line 667 of file Texture.hpp.

◆ createTexture3D() [1/3]

bool vl::Texture::createTexture3D ( int  width,
int  height,
int  depth,
ETextureFormat  format,
bool  border = false 
)
inline

Creates an empty 3D texture.

Definition at line 385 of file Texture.hpp.

◆ createTexture3D() [2/3]

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

Creates a 3D texture from the specified file.

Definition at line 399 of file Texture.hpp.

◆ createTexture3D() [3/3]

bool vl::Texture::createTexture3D ( const Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
)
inline

Creates a 3D texture from the specified image.

Definition at line 417 of file Texture.hpp.

◆ createTextureBuffer()

bool vl::Texture::createTextureBuffer ( vl::ETextureFormat  format,
BufferObject bo 
)
inline

Creates a texture buffer texture.

The BufferObject can come from an Array* or from ImagePBO or can be a stand-alone BufferObject as well.

Definition at line 624 of file Texture.hpp.

◆ createTextureCubemap() [1/3]

bool vl::Texture::createTextureCubemap ( int  width,
int  height,
ETextureFormat  format,
bool  border = false 
)
inline

Creates an empty cubemap texture.

Definition at line 432 of file Texture.hpp.

◆ createTextureCubemap() [2/3]

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

Creates creation a cubemap texture from the specified file.

Definition at line 446 of file Texture.hpp.

◆ createTextureCubemap() [3/3]

bool vl::Texture::createTextureCubemap ( const Image image,
ETextureFormat  format,
bool  mipmaps = true,
bool  border = false 
)
inline

Creates a cubemap texture from the specified image.

Definition at line 464 of file Texture.hpp.

◆ createTextureRectangle() [1/3]

bool vl::Texture::createTextureRectangle ( int  width,
int  height,
ETextureFormat  format 
)
inline

Creates an empty texture rectangle.

Definition at line 574 of file Texture.hpp.

◆ createTextureRectangle() [2/3]

bool vl::Texture::createTextureRectangle ( const String image_path,
ETextureFormat  format 
)
inline

Creates a texture rectangle from the specified file.

Definition at line 588 of file Texture.hpp.

◆ createTextureRectangle() [3/3]

bool vl::Texture::createTextureRectangle ( const Image image,
ETextureFormat  format 
)
inline

Creates a texture rectangle from the specified image.

Definition at line 606 of file Texture.hpp.

◆ depth()

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

The z dimension of the texture in texels.

Definition at line 710 of file Texture.hpp.

Referenced by setMipLevel(), and vl::RaycastVolume::updateUniforms().

◆ destroyTexture()

void Texture::destroyTexture ( )

Destroys the GL texture object if managed() is true (default).

TexParameter is not reset but is marked dirty. After calling this function the vl::Texture values are reset() including managed() which is set to true.

Definition at line 359 of file Texture.cpp.

References mHandle, mManaged, and VL_CHECK_OGL.

Referenced by createTexture(), and ~Texture().

◆ dimension()

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

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

Definition at line 690 of file Texture.hpp.

Referenced by setMipLevel().

◆ fixedSamplesLocation()

bool vl::Texture::fixedSamplesLocation ( ) const
inline

Whether the samples location is fixed for a a multisample texture.

Definition at line 725 of file Texture.hpp.

◆ getTexParameter() [1/2]

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

◆ getTexParameter() [2/2]

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

The TexParameter object associated to a Texture.

Definition at line 249 of file Texture.hpp.

◆ getTexParameterOverride()

const TexParameter* vl::Texture::getTexParameterOverride ( ) const
inline

The TexParameter belonging to a TextureSampler that is currently overriding the Texture's own TexParameter.

Definition at line 252 of file Texture.hpp.

◆ handle()

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

OpenGL texture handle as returned by glGenTextures().

Definition at line 678 of file Texture.hpp.

Referenced by vl::Rendering::fillRenderQueue(), and isValid().

◆ height()

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

The vertical dimension of the texture in texels.

Definition at line 705 of file Texture.hpp.

Referenced by setMipLevel(), and vl::RaycastVolume::updateUniforms().

◆ internalFormat()

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

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

Definition at line 695 of file Texture.hpp.

Referenced by isDepthTexture(), and setMipLevel().

◆ isCompressedFormat()

bool Texture::isCompressedFormat ( int  format)
static

◆ isDepthTexture()

bool Texture::isDepthTexture ( ) const

◆ isValid()

bool Texture::isValid ( ) const

Returns true if the current texture configuration seems valid.

Definition at line 490 of file Texture.cpp.

References handle(), mDepth, mHeight, and mWidth.

◆ managed()

bool vl::Texture::managed ( ) const
inline

If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or destroyTexture() is called.

See also destroyTexture().

Definition at line 685 of file Texture.hpp.

◆ prepareTexture1D() [1/3]

void vl::Texture::prepareTexture1D ( int  width,
ETextureFormat  format,
bool  border = false 
)
inline

Prepares for creation an empty 1D texture.

Definition at line 283 of file Texture.hpp.

References NULL.

Referenced by Texture().

◆ prepareTexture1D() [2/3]

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.

Definition at line 297 of file Texture.hpp.

References NULL.

◆ prepareTexture1D() [3/3]

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

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

Definition at line 311 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_1D.

◆ prepareTexture1DArray() [1/3]

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

Prepares for creation an empty 1D array texture.

Definition at line 471 of file Texture.hpp.

References NULL.

◆ prepareTexture1DArray() [2/3]

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.

Definition at line 486 of file Texture.hpp.

References NULL.

◆ prepareTexture1DArray() [3/3]

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

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

Definition at line 500 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_1D_ARRAY.

◆ prepareTexture2D() [1/3]

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

Prepares for creation an empty 2D texture.

Definition at line 329 of file Texture.hpp.

References NULL.

Referenced by vl::load3DS(), vl::loadAC3D(), vl::ObjLoader::loadOBJ(), and Texture().

◆ prepareTexture2D() [2/3]

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.

Definition at line 344 of file Texture.hpp.

References NULL.

◆ prepareTexture2D() [3/3]

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

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

Definition at line 358 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_2D.

◆ prepareTexture2DArray() [1/3]

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

Prepares for creation an empty 2D array texture.

Definition at line 518 of file Texture.hpp.

References NULL.

◆ prepareTexture2DArray() [2/3]

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.

Definition at line 534 of file Texture.hpp.

References NULL.

◆ prepareTexture2DArray() [3/3]

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

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

Definition at line 548 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_2D_ARRAY.

◆ prepareTexture2DMultisample()

void vl::Texture::prepareTexture2DMultisample ( int  width,
int  height,
vl::ETextureFormat  format,
int  samples,
bool  fixedsamplelocations 
)
inline

Prepares a 2D multisample texture.

Definition at line 631 of file Texture.hpp.

References vl::Texture::SetupParams::setDimension(), and vl::TD_TEXTURE_2D_MULTISAMPLE.

◆ prepareTexture2DMultisampleArray()

void vl::Texture::prepareTexture2DMultisampleArray ( int  width,
int  height,
int  depth,
vl::ETextureFormat  format,
int  samples,
bool  fixedsamplelocations 
)
inline

Prepares a 3D multisample texture.

Definition at line 652 of file Texture.hpp.

References vl::Texture::SetupParams::setDimension(), and vl::TD_TEXTURE_2D_MULTISAMPLE_ARRAY.

◆ prepareTexture3D() [1/3]

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

Prepares for creation an empty 3D texture.

Definition at line 376 of file Texture.hpp.

References NULL.

Referenced by Texture().

◆ prepareTexture3D() [2/3]

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.

Definition at line 392 of file Texture.hpp.

References NULL.

◆ prepareTexture3D() [3/3]

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

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

Definition at line 406 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_3D.

◆ prepareTextureBuffer()

void vl::Texture::prepareTextureBuffer ( vl::ETextureFormat  format,
BufferObject bo 
)
inline

Prepares a texture buffer texture.

The BufferObject can come from an Array* or from ImagePBO or can be a stand-alone BufferObject as well.

Definition at line 613 of file Texture.hpp.

References vl::Texture::SetupParams::setDimension(), and vl::TD_TEXTURE_BUFFER.

◆ prepareTextureCubemap() [1/3]

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

Prepares for creation an empty cubemap texture.

Definition at line 424 of file Texture.hpp.

References NULL.

Referenced by Texture().

◆ prepareTextureCubemap() [2/3]

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.

Definition at line 439 of file Texture.hpp.

References NULL.

◆ prepareTextureCubemap() [3/3]

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

Prepares for creation a cubemap texture from the specified image.

Definition at line 453 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_CUBE_MAP.

◆ prepareTextureRectangle() [1/3]

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

Prepares for creation an empty texture rectangle.

Definition at line 566 of file Texture.hpp.

References NULL.

◆ prepareTextureRectangle() [2/3]

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

Prepares for creation a texture rectangle from the specified file.

Definition at line 581 of file Texture.hpp.

References NULL.

◆ prepareTextureRectangle() [3/3]

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

Prepares for creation a texture rectangle from the specified image.

Definition at line 595 of file Texture.hpp.

References vl::Texture::SetupParams::setImage(), and vl::TD_TEXTURE_RECTANGLE.

◆ samples()

int vl::Texture::samples ( ) const
inline

The number of samples of a multisample texture.

Definition at line 720 of file Texture.hpp.

Referenced by createTexture().

◆ setBorder()

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

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

Definition at line 713 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ setDepth()

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

The z dimension of the texture in texels.

Definition at line 708 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ setDimension()

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

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

Definition at line 688 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ setFixedSamplesLocation()

void vl::Texture::setFixedSamplesLocation ( bool  fixed)
inline

Whether the samples location is fixed for a a multisample texture.

Definition at line 723 of file Texture.hpp.

◆ setHandle()

void vl::Texture::setHandle ( unsigned int  id,
bool  managed = true 
)
inline

OpenGL texture handle as returned by glGenTextures().

If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or destroyTexture() is called. See also destroyTexture().

Definition at line 676 of file Texture.hpp.

◆ setHeight()

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

The vertical dimension of the texture in texels.

Definition at line 703 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ setInternalFormat()

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

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

Definition at line 693 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ setManaged()

void vl::Texture::setManaged ( bool  managed)
inline

If managed is true the texture will be automatically destroyed when the vl::Texture is destroyed or destroyTexture() is called.

See also destroyTexture().

Definition at line 682 of file Texture.hpp.

◆ setMipLevel()

bool Texture::setMipLevel ( int  mip_level,
const 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.

Parameters
mip_levelThe mip-mapping level to be modified.
imgThe Image containing the pixels to be copied into the specified mip-mapping level.
gen_mipmapsIf 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.

Definition at line 844 of file Texture.cpp.

References border(), vl::Log::bug(), vl::Image::byteAlignment(), vl::Image::depth(), depth(), vl::Image::dimension(), dimension(), vl::Log::error(), vl::Image::format(), vl::Has_GL_GENERATE_MIPMAP, vl::Has_glGenerateMipmaps, vl::Image::height(), height(), internalFormat(), isCompressedFormat(), mHandle, vl::Image::pixels(), vl::Image::pixelsXN(), vl::Image::pixelsXP(), vl::Image::pixelsYN(), vl::Image::pixelsYP(), vl::Image::pixelsZN(), vl::Image::pixelsZP(), vl::Image::requiredMemory(), supports(), vl::TD_TEXTURE_1D, vl::TD_TEXTURE_1D_ARRAY, vl::TD_TEXTURE_2D, vl::TD_TEXTURE_2D_ARRAY, vl::TD_TEXTURE_2D_MULTISAMPLE, vl::TD_TEXTURE_2D_MULTISAMPLE_ARRAY, vl::TD_TEXTURE_3D, vl::TD_TEXTURE_BUFFER, vl::TD_TEXTURE_CUBE_MAP, vl::TD_TEXTURE_RECTANGLE, vl::Image::type(), VL_CHECK, VL_CHECK_OGL, VL_IS_POW_2, VL_TRAP, vl::Log::warning(), vl::Image::width(), and width().

Referenced by createTexture().

◆ setSamples()

void vl::Texture::setSamples ( int  samples)
inline

The number of samples of a multisample texture.

Definition at line 718 of file Texture.hpp.

◆ setSetupParams()

void vl::Texture::setSetupParams ( SetupParams setup_params)
inline

See SetupParams.

Definition at line 728 of file Texture.hpp.

Referenced by vlX::VLXClassWrapper_Texture::importTexture().

◆ setupParams() [1/2]

const SetupParams* vl::Texture::setupParams ( ) const
inline

◆ setupParams() [2/2]

SetupParams* vl::Texture::setupParams ( )
inline

See SetupParams.

Definition at line 734 of file Texture.hpp.

◆ setWidth()

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

The horizontal dimension of the texture in texels.

Definition at line 698 of file Texture.hpp.

Referenced by createTexture(), and ~Texture().

◆ supports()

bool Texture::supports ( ETextureDimension  tex_dimension,
ETextureFormat  tex_format,
int  mip_level,
EImageDimension  img_dimension,
int  w,
int  h,
int  d,
bool  border,
int  samples,
bool  fixedsamplelocations,
bool  verbose 
)
static

◆ width()

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

The horizontal dimension of the texture in texels.

Definition at line 700 of file Texture.hpp.

Referenced by setMipLevel(), supports(), and vl::RaycastVolume::updateUniforms().

Friends And Related Function Documentation

◆ TextureSampler

friend class TextureSampler
friend

Definition at line 146 of file Texture.hpp.

Member Data Documentation

◆ mBorder

bool vl::Texture::mBorder
protected

Definition at line 771 of file Texture.hpp.

Referenced by clone().

◆ mBufferObject

ref<BufferObject> vl::Texture::mBufferObject
protected

Definition at line 764 of file Texture.hpp.

Referenced by clone(), createTexture(), and ~Texture().

◆ mDepth

int vl::Texture::mDepth
protected

Definition at line 769 of file Texture.hpp.

Referenced by clone(), and isValid().

◆ mDimension

ETextureDimension vl::Texture::mDimension
protected

Definition at line 766 of file Texture.hpp.

Referenced by clone().

◆ mFixedSamplesLocation

bool vl::Texture::mFixedSamplesLocation
protected

Definition at line 772 of file Texture.hpp.

Referenced by clone(), createTexture(), and ~Texture().

◆ mFormat

ETextureFormat vl::Texture::mFormat
protected

Definition at line 765 of file Texture.hpp.

Referenced by clone().

◆ mHandle

unsigned int vl::Texture::mHandle
protected

Definition at line 759 of file Texture.hpp.

Referenced by clone(), createTexture(), destroyTexture(), setMipLevel(), and ~Texture().

◆ mHeight

int vl::Texture::mHeight
protected

Definition at line 768 of file Texture.hpp.

Referenced by clone(), and isValid().

◆ mManaged

bool vl::Texture::mManaged
protected

Definition at line 760 of file Texture.hpp.

Referenced by destroyTexture(), and ~Texture().

◆ mSamples

int vl::Texture::mSamples
protected

Definition at line 770 of file Texture.hpp.

Referenced by clone(), createTexture(), and ~Texture().

◆ mSetupParams

ref<SetupParams> vl::Texture::mSetupParams
protected

Definition at line 763 of file Texture.hpp.

Referenced by clone(), createTexture(), and ~Texture().

◆ mTexParameter

ref<TexParameter> vl::Texture::mTexParameter
protected

Definition at line 761 of file Texture.hpp.

Referenced by clone(), Texture(), and ~Texture().

◆ mTexParameterOverride

ref<TexParameter> vl::Texture::mTexParameterOverride
mutableprotected

Definition at line 762 of file Texture.hpp.

◆ mWidth

int vl::Texture::mWidth
protected

Definition at line 767 of file Texture.hpp.

Referenced by clone(), and isValid().


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