|
CGVIS Utils
|
#include <GLTexture2D.h>
Public Member Functions | |
| GLTexture2D (GLint magFilter=GL_NEAREST, GLint minFilter=GL_NEAREST, GLint wrapX=GL_REPEAT, GLint wrapY=GL_REPEAT) | |
| Create an empty GL_TEXTURE_2D and set sampler parameters. | |
| ~GLTexture2D () | |
| Destroy and delete the GL texture name. | |
| GLTexture2D (const Image &image, GLint magFilter=GL_NEAREST, GLint minFilter=GL_NEAREST, GLint wrapX=GL_REPEAT, GLint wrapY=GL_REPEAT) | |
| Construct a texture and immediately upload from an Image. | |
| GLTexture2D (const GLTexture2D &other) | |
| Copy-construct and duplicate texture contents and parameters. | |
| GLTexture2D & | operator= (const GLTexture2D &other) |
| Copy-assign and duplicate texture contents and parameters. | |
| const GLuint | getId () const |
| Retrieve the OpenGL texture object name. | |
| void | clear () |
| Clear the texture to an empty image preserving dimensions/type. | |
| void | setEmpty (uint32_t width, uint32_t height, uint8_t componentCount, GLDataType dataType=GLDataType::BYTE) |
| Allocate an empty texture of given size and format. | |
| void | setData (const Image &image) |
| Upload from an Image (bytes). | |
| void | setData (const std::vector< GLubyte > &data, uint32_t width, uint32_t height, uint8_t componentCount=4) |
| Upload unsigned-byte data with explicit dimensions. | |
| void | setData (const std::vector< GLubyte > &data) |
| Upload unsigned-byte data using previously set dimensions. | |
| void | setData (const std::vector< GLfloat > &data, uint32_t width, uint32_t height, uint8_t componentCount=4) |
| Upload float data with explicit dimensions. | |
| void | setData (const std::vector< GLfloat > &data) |
| Upload float data using previously set dimensions. | |
| void | setData (const std::vector< GLhalf > &data, uint32_t width, uint32_t height, uint8_t componentCount=4) |
| Upload 16-bit half-float data with explicit dimensions. | |
| void | setData (const std::vector< GLhalf > &data) |
| Upload 16-bit half-float data using previously set dimensions. | |
| void | setFilter (GLint magFilter, GLint minFilter) |
| Update filtering parameters on the bound texture. | |
| void | setPixel (const std::vector< GLubyte > &data, uint32_t x, uint32_t y) |
| Replace a single pixel at (x,y) with unsigned-byte RGBA/RGB/etc. | |
| void | generateMipmap () |
| Generate mipmaps for the texture. | |
| Image | getImage () |
| Read back texture as an Image (BYTE). | |
| const std::vector< GLubyte > & | getDataByte () |
| Read back raw unsigned bytes via glGetTexImage. | |
| const std::vector< GLhalf > & | getDataHalf () |
| Read back raw half floats via glGetTexImage. | |
| const std::vector< GLfloat > & | getDataFloat () |
| Read back raw floats via glGetTexImage. | |
Introspection | |
| uint32_t | getHeight () const |
| uint32_t | getWidth () const |
| uint32_t | getComponentCount () const |
| uint32_t | getSize () const |
| GLDataType | getType () const |
| GLTexture2D::GLTexture2D | ( | GLint | magFilter = GL_NEAREST, |
| GLint | minFilter = GL_NEAREST, | ||
| GLint | wrapX = GL_REPEAT, | ||
| GLint | wrapY = GL_REPEAT ) |
Create an empty GL_TEXTURE_2D and set sampler parameters.
| magFilter | GL magnification filter (e.g., GL_NEAREST/GL_LINEAR). |
| minFilter | GL minification filter (e.g., GL_NEAREST/GL_LINEAR). |
| wrapX | GL wrap mode for S (x) coordinate (e.g., GL_REPEAT). |
| wrapY | GL wrap mode for T (y) coordinate. |
| GLTexture2D::~GLTexture2D | ( | ) |
Destroy and delete the GL texture name.
| GLTexture2D::GLTexture2D | ( | const Image & | image, |
| GLint | magFilter = GL_NEAREST, | ||
| GLint | minFilter = GL_NEAREST, | ||
| GLint | wrapX = GL_REPEAT, | ||
| GLint | wrapY = GL_REPEAT ) |
Construct a texture and immediately upload from an Image.
| image | Source image (bytes, interleaved). |
| magFilter | GL magnification filter. |
| minFilter | GL minification filter. |
| wrapX | Wrap mode for S. |
| wrapY | Wrap mode for T. |
| GLTexture2D::GLTexture2D | ( | const GLTexture2D & | other | ) |
Copy-construct and duplicate texture contents and parameters.
| void GLTexture2D::clear | ( | ) |
Clear the texture to an empty image preserving dimensions/type.
| void GLTexture2D::generateMipmap | ( | ) |
Generate mipmaps for the texture.
|
inline |
| const std::vector< GLubyte > & GLTexture2D::getDataByte | ( | ) |
Read back raw unsigned bytes via glGetTexImage.
| const std::vector< GLfloat > & GLTexture2D::getDataFloat | ( | ) |
Read back raw floats via glGetTexImage.
| const std::vector< GLhalf > & GLTexture2D::getDataHalf | ( | ) |
Read back raw half floats via glGetTexImage.
|
inline |
| const GLuint GLTexture2D::getId | ( | ) | const |
Retrieve the OpenGL texture object name.
| Image GLTexture2D::getImage | ( | ) |
|
inline |
|
inline |
|
inline |
| GLTexture2D & GLTexture2D::operator= | ( | const GLTexture2D & | other | ) |
Copy-assign and duplicate texture contents and parameters.
| void GLTexture2D::setData | ( | const Image & | image | ) |
Upload from an Image (bytes).
| image | Source image; width/height/components taken from it. |
| void GLTexture2D::setData | ( | const std::vector< GLfloat > & | data | ) |
Upload float data using previously set dimensions.
| data | Interleaved float pixels of size getSize(). |
| void GLTexture2D::setData | ( | const std::vector< GLfloat > & | data, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| uint8_t | componentCount = 4 ) |
Upload float data with explicit dimensions.
| data | Interleaved float pixels of size componentCount*width*height. |
| width | Width in texels. |
| height | Height in texels. |
| componentCount | Components per texel (default 4 = RGBA). |
| GLException | if sizes do not match. |
| void GLTexture2D::setData | ( | const std::vector< GLhalf > & | data | ) |
Upload 16-bit half-float data using previously set dimensions.
| data | Interleaved half-float pixels of size getSize(). |
| void GLTexture2D::setData | ( | const std::vector< GLhalf > & | data, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| uint8_t | componentCount = 4 ) |
Upload 16-bit half-float data with explicit dimensions.
| data | Interleaved half-float pixels (GLhalf) of size componentCount*width*height. |
| width | Width in texels. |
| height | Height in texels. |
| componentCount | Components per texel (default 4 = RGBA). |
| GLException | if sizes do not match. |
| void GLTexture2D::setData | ( | const std::vector< GLubyte > & | data | ) |
Upload unsigned-byte data using previously set dimensions.
| data | Interleaved pixel bytes of size getSize(). |
| void GLTexture2D::setData | ( | const std::vector< GLubyte > & | data, |
| uint32_t | width, | ||
| uint32_t | height, | ||
| uint8_t | componentCount = 4 ) |
Upload unsigned-byte data with explicit dimensions.
| data | Interleaved pixel bytes of size componentCount*width*height. |
| width | Width in texels. |
| height | Height in texels. |
| componentCount | Components per texel (default 4 = RGBA). |
| GLException | if sizes do not match. |
| void GLTexture2D::setEmpty | ( | uint32_t | width, |
| uint32_t | height, | ||
| uint8_t | componentCount, | ||
| GLDataType | dataType = GLDataType::BYTE ) |
Allocate an empty texture of given size and format.
| width | Width in texels. |
| height | Height in texels. |
| componentCount | Components per texel (1..4). |
| dataType | Element type (BYTE/HALF/FLOAT). |
| void GLTexture2D::setFilter | ( | GLint | magFilter, |
| GLint | minFilter ) |
Update filtering parameters on the bound texture.
| magFilter | GL magnification filter. |
| minFilter | GL minification filter. |
| void GLTexture2D::setPixel | ( | const std::vector< GLubyte > & | data, |
| uint32_t | x, | ||
| uint32_t | y ) |
Replace a single pixel at (x,y) with unsigned-byte RGBA/RGB/etc.
| data | Bytes for one texel (size = componentCount). |
| x | X coordinate (0..width-1). |
| y | Y coordinate (0..height-1). |