15#ifndef TEXTURE_H_6014714286
16#define TEXTURE_H_6014714286
45template<
unsigned int dimension >
48 static_assert(
dimension >= 1 &&
dimension <= 3,
"Texture dimension must be 1, 2 or 3." );
90 const unsigned int id;
101 const static unsigned int SETUP_UNIT = 0;
119 (
const Eigen::Matrix< unsigned int, 1, 1 >& size
123 ,
const void* bufferPtr );
133 ,
const void* bufferPtr );
143 ,
const void* bufferPtr );
158template<
unsigned int dimension >
166 typedef Eigen::Matrix< unsigned int, dimension, 1 >
Resolution;
210 void bind(
unsigned int unit )
const;
237 std::unique_ptr< Resolution > mySize;
242template<
unsigned int dimension >
244 : internalFormat( internalFormat )
245 , pixelFormat( pixelFormat )
247 static_assert(
dimension >= 1 &&
dimension <= 3,
"Texture dimension must be 1, 2 or 3." );
252template<
unsigned int dimension >
259template<
unsigned int dimension >
262 return mySize.
get() !=
nullptr;
266template<
unsigned int dimension >
274template<
unsigned int dimension >
293 this->bind( SETUP_UNIT );
294 uploadGLTextureData( size, internalFormat, pixelFormat, bufferType, bufferPtr );
298template<
unsigned int dimension >
301 update( size, 0,
nullptr );
Defines LibCarna::base::LibCarnaException and LibCarna::base::AssertionFailure.
#define LIBCARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
#define LIBCARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Contains forward-declarations.
Represents an association.
AssociatedObjectType * get() const
Returns raw pointer to the referenced object.
Texture base class with dimension-independent definitions.
void uploadGLTextureData(const math::Vector2ui &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
Wraps glTexImage2d.
void uploadGLTextureData(const Eigen::Matrix< unsigned int, 1, 1 > &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
Wraps glTexImage1d.
void bindGLTextureObject(unsigned int unit, unsigned int id)
Binds OpenGL texture object id to texture unit. For internal usage only, use Texture::bind instead.
static unsigned int maxTextureSize()
Queries GL_MAX_TEXTURE_SIZE from the current GL context.
TextureBase()
Creates OpenGL texture object.
const unsigned int id
Holds the ID of the represented OpenGL texture object.
void uploadGLTextureData(const math::Vector3ui &size, int internalFormat, int pixelFormat, int bufferType, const void *bufferPtr)
Wraps glTexImage3d.
virtual ~TextureBase()
Deletes the maintained OpenGL texture object.
Represents an OpenGL texture object. This class realizes the RAII-idiom.
const int internalFormat
Holds the number of color components in the texture, e.g. GL_RGBA8UI or GL_INTENSITY16.
static const unsigned int DIMENSION
Holds the dimension of this texture.
Texture(int internalFormat, int pixelFormat)
Creates OpenGL texture object.
Eigen::Matrix< unsigned int, dimension, 1 > Resolution
void update(const Resolution &size)
void bind(unsigned int unit) const
Binds this texture to unit. Consider using TextureBase::SETUP_UNIT if you're binding the texture temp...
void update(const Resolution &size, int bufferType, const void *bufferPtr)
const Resolution & size() const
Tells the resolution of this texture.
const int pixelFormat
Holds the format of the pixel data, e.g. GL_RED, GL_RGB or GL_RGBA.
bool isValid() const
Tells whether the texture has been initialized, i.e. it has a size.
Defines LibCarna::base::math namespace and LIBCARNA_FOR_VECTOR3UI.
Eigen::Matrix< unsigned int, 2, 1 > Vector2ui
Defines vector.
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
void bindGLTextureObject< 3 >(unsigned int unit, unsigned int id)
void bindGLTextureObject< 1 >(unsigned int unit, unsigned int id)
void bindGLTextureObject< 2 >(unsigned int unit, unsigned int id)
Defines LibCarna::base::noncopyable and NON_COPYABLE.
#define NON_COPYABLE
Marks the class that it is placed in as non-copyable.