12 #ifndef TEXTURE_H_6014714286 13 #define TEXTURE_H_6014714286 15 #include <Carna/Carna.h> 41 template<
unsigned int dimension >
44 static_assert( dimension >= 1 && dimension <= 3,
"Texture dimension must be 1, 2 or 3." );
87 const unsigned int id;
98 const static unsigned int SETUP_UNIT = 0;
110 void uploadGLTextureData
111 (
const Eigen::Matrix< unsigned int, 1, 1 >& size
115 ,
const void* bufferPtr );
120 void uploadGLTextureData
125 ,
const void* bufferPtr );
130 void uploadGLTextureData
135 ,
const void* bufferPtr );
151 template<
unsigned int dimension >
159 typedef Eigen::Matrix< unsigned int, dimension, 1 >
Resolution;
178 Texture(
int internalFormat,
int pixelFormat );
183 const static unsigned int DIMENSION = dimension;
189 const Resolution& size()
const;
194 bool isValid()
const;
203 void bind(
unsigned int unit )
const;
222 void update(
const Resolution& size,
int bufferType,
const void* bufferPtr );
226 void update(
const Resolution& size );
230 std::unique_ptr< Resolution > mySize;
235 template<
unsigned int dimension >
237 : internalFormat( internalFormat )
238 , pixelFormat( pixelFormat )
240 static_assert( dimension >= 1 && dimension <= 3,
"Texture dimension must be 1, 2 or 3." );
245 template<
unsigned int dimension >
248 bindGLTextureObject< dimension >( unit, id );
252 template<
unsigned int dimension >
255 return mySize.get() !=
nullptr;
259 template<
unsigned int dimension >
267 template<
unsigned int dimension >
272 for(
unsigned int i = 0; i < dimension; ++i )
274 CARNA_ASSERT_EX( size( i, 0 ) >= 1,
"Texture only supports positive sizes!" );
281 CARNA_ASSERT_EX( size( 2, 0 ) % 2 == 0,
"3D textures must have even depth!" );
286 this->bind( SETUP_UNIT );
287 uploadGLTextureData( size, internalFormat, pixelFormat, bufferType, bufferPtr );
291 template<
unsigned int dimension >
294 update( size, 0,
nullptr );
303 #endif // TEXTURE_H_6014714286 Defines Carna::base::math namespace and CARNA_FOR_VECTOR3UI.
const int pixelFormat
Holds the format of the pixel data, e.g. GL_RED, GL_RGB or GL_RGBA.
void bindGLTextureObject< 1 >(unsigned int unit, unsigned int id)
#define CARNA_ASSERT_EX(expression, description)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
void bindGLTextureObject< 2 >(unsigned int unit, unsigned int id)
Eigen::Matrix< unsigned int, 3, 1 > Vector3ui
Defines vector.
const int internalFormat
Holds the number of color components in the texture, e.g. GL_RGBA8UI or GL_INTENSITY16.
void bindGLTextureObject(unsigned int unit, unsigned int id)
Binds OpenGL texture object id to texture unit. For internal usage only, use Texture::bind instead...
const unsigned int id
Holds the ID of the represented OpenGL texture object.
Represents an OpenGL texture object. This class realizes the RAII-idiom.
Defines Carna::base::CarnaException, Carna::base::AssertionFailure.
Texture base class with dimension-independent definitions.
void bindGLTextureObject< 3 >(unsigned int unit, unsigned int id)
Texture(int internalFormat, int pixelFormat)
Creates OpenGL texture object.
Eigen::Matrix< unsigned int, 2, 1 > Vector2ui
Defines vector.
#define CARNA_ASSERT(expression)
If the given expression is false, a break point is raised in debug mode and an AssertionFailure throw...
Eigen::Matrix< unsigned int, dimension, 1 > Resolution
#define NON_COPYABLE
Features class it is placed in as non-copyable.