Carna  Version 3.0.1
Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Carna::base::Texture< dimension > Class Template Reference

Represents an OpenGL texture object. This class realizes the RAII-idiom. More...

#include <Texture.h>

+ Inheritance diagram for Carna::base::Texture< dimension >:
+ Collaboration diagram for Carna::base::Texture< dimension >:

Public Types

typedef Eigen::Matrix< unsigned int, dimension, 1 > Resolution
 

Public Member Functions

 Texture (int internalFormat, int pixelFormat)
 Creates OpenGL texture object. More...
 
const Resolutionsize () const
 Tells the resolution of this texture. More...
 
bool isValid () const
 Tells whether the texture has been initialized, i.e. it has a size.
 
void bind (unsigned int unit) const
 Binds this texture to unit. Consider using TextureBase::SETUP_UNIT if you're binding the texture temporarily.
 
void update (const Resolution &size, int bufferType, const void *bufferPtr)
 
void update (const Resolution &size)
 
- Public Member Functions inherited from Carna::base::TextureBase
virtual ~TextureBase ()
 Deletes the maintained OpenGL texture object.
 

Public Attributes

const int internalFormat
 Holds the number of color components in the texture, e.g. GL_RGBA8UI or GL_INTENSITY16.
 
const int pixelFormat
 Holds the format of the pixel data, e.g. GL_RED, GL_RGB or GL_RGBA.
 
- Public Attributes inherited from Carna::base::TextureBase
const unsigned int id
 Holds the ID of the represented OpenGL texture object.
 

Static Public Attributes

static const unsigned int DIMENSION = dimension
 Holds the dimension of this texture.
 
- Static Public Attributes inherited from Carna::base::TextureBase
static const unsigned int SETUP_UNIT = 0
 Texture unit that is fine to be used for temporal bindings, i.e. for setting textures up. This unit shouldn't be used for lasting bindings.
 

Additional Inherited Members

- Protected Member Functions inherited from Carna::base::TextureBase
 TextureBase ()
 Creates OpenGL texture object.
 
void uploadGLTextureData (const Eigen::Matrix< unsigned int, 1, 1 > &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
 Wraps glTexImage1d.
 
void uploadGLTextureData (const math::Vector2ui &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
 Wraps glTexImage2d.
 
void uploadGLTextureData (const math::Vector3ui &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
 Wraps glTexImage3d.
 

Detailed Description

template<unsigned int dimension>
class Carna::base::Texture< dimension >

Represents an OpenGL texture object. This class realizes the RAII-idiom.

Author
Leonid Kostrykin
Date
22.2.15 - 24.3.15

Definition at line 152 of file Texture.h.

Member Typedef Documentation

template<unsigned int dimension>
typedef Eigen::Matrix< unsigned int, dimension, 1 > Carna::base::Texture< dimension >::Resolution

Holds the resolution type of this texture.

Definition at line 159 of file Texture.h.

Constructor & Destructor Documentation

template<unsigned int dimension>
Carna::base::Texture< dimension >::Texture ( int  internalFormat,
int  pixelFormat 
)

Creates OpenGL texture object.

Postcondition
isValid() == false
Parameters
internalFormatspecifies the number of color components in the texture, e.g. GL_RGBA8UI or GL_INTENSITY16.
pixelFormatspecifies the format of the pixel data, e.g. GL_RED, GL_RGB or GL_RGBA.
See also
Valid values for the parameters are available here: https://www.opengl.org/sdk/docs/man3/xhtml/glTexImage3D.xml

Definition at line 236 of file Texture.h.

Member Function Documentation

template<unsigned int dimension>
const Eigen::Matrix< unsigned int, dimension, 1 > & Carna::base::Texture< dimension >::size ( ) const

Tells the resolution of this texture.

Precondition
isValid() == true

Definition at line 260 of file Texture.h.

template<unsigned int dimension>
void Carna::base::Texture< dimension >::update ( const Resolution size,
int  bufferType,
const void *  bufferPtr 
)

Binds this texture to TextureBase::SETUP_UNIT, updates its size and data.

Postcondition
isValid() == true
Parameters
sizeis the new resolution of this texture.
bufferTypespecifies the data type of the pixel data pointed to by bufferPtr.
bufferPtrpoints to the pixel data that will be uploaded to the texture.

No data is uploaded to the texture if nullptr is given for bufferPtr. The value of bufferType has no meaning than.

Definition at line 268 of file Texture.h.

template<unsigned int dimension>
void Carna::base::Texture< dimension >::update ( const Resolution size)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 292 of file Texture.h.


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