CGVIS Utils
Loading...
Searching...
No Matches
GLTexture2D Class Reference

#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

Constructor & Destructor Documentation

◆ GLTexture2D() [1/3]

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.

Parameters
magFilterGL magnification filter (e.g., GL_NEAREST/GL_LINEAR).
minFilterGL minification filter (e.g., GL_NEAREST/GL_LINEAR).
wrapXGL wrap mode for S (x) coordinate (e.g., GL_REPEAT).
wrapYGL wrap mode for T (y) coordinate.
Postcondition
A texture object is generated and the given parameters are applied.
Here is the caller graph for this function:

◆ ~GLTexture2D()

GLTexture2D::~GLTexture2D ( )

Destroy and delete the GL texture name.

◆ GLTexture2D() [2/3]

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.

Parameters
imageSource image (bytes, interleaved).
magFilterGL magnification filter.
minFilterGL minification filter.
wrapXWrap mode for S.
wrapYWrap mode for T.
Here is the call graph for this function:

◆ GLTexture2D() [3/3]

GLTexture2D::GLTexture2D ( const GLTexture2D & other)

Copy-construct and duplicate texture contents and parameters.

Here is the call graph for this function:

Member Function Documentation

◆ clear()

void GLTexture2D::clear ( )

Clear the texture to an empty image preserving dimensions/type.

Here is the call graph for this function:

◆ generateMipmap()

void GLTexture2D::generateMipmap ( )

Generate mipmaps for the texture.

◆ getComponentCount()

uint32_t GLTexture2D::getComponentCount ( ) const
inline

◆ getDataByte()

const std::vector< GLubyte > & GLTexture2D::getDataByte ( )

Read back raw unsigned bytes via glGetTexImage.

Here is the caller graph for this function:

◆ getDataFloat()

const std::vector< GLfloat > & GLTexture2D::getDataFloat ( )

Read back raw floats via glGetTexImage.

◆ getDataHalf()

const std::vector< GLhalf > & GLTexture2D::getDataHalf ( )

Read back raw half floats via glGetTexImage.

◆ getHeight()

uint32_t GLTexture2D::getHeight ( ) const
inline
Here is the caller graph for this function:

◆ getId()

const GLuint GLTexture2D::getId ( ) const

Retrieve the OpenGL texture object name.

Returns
GLuint of the managed GL_TEXTURE_2D.
Here is the caller graph for this function:

◆ getImage()

Image GLTexture2D::getImage ( )

Read back texture as an Image (BYTE).

Here is the call graph for this function:

◆ getSize()

uint32_t GLTexture2D::getSize ( ) const
inline

◆ getType()

GLDataType GLTexture2D::getType ( ) const
inline

◆ getWidth()

uint32_t GLTexture2D::getWidth ( ) const
inline
Here is the caller graph for this function:

◆ operator=()

GLTexture2D & GLTexture2D::operator= ( const GLTexture2D & other)

Copy-assign and duplicate texture contents and parameters.

Here is the call graph for this function:

◆ setData() [1/7]

void GLTexture2D::setData ( const Image & image)

Upload from an Image (bytes).

Parameters
imageSource image; width/height/components taken from it.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setData() [2/7]

void GLTexture2D::setData ( const std::vector< GLfloat > & data)

Upload float data using previously set dimensions.

Parameters
dataInterleaved float pixels of size getSize().
Here is the call graph for this function:

◆ setData() [3/7]

void GLTexture2D::setData ( const std::vector< GLfloat > & data,
uint32_t width,
uint32_t height,
uint8_t componentCount = 4 )

Upload float data with explicit dimensions.

Parameters
dataInterleaved float pixels of size componentCount*width*height.
widthWidth in texels.
heightHeight in texels.
componentCountComponents per texel (default 4 = RGBA).
Exceptions
GLExceptionif sizes do not match.
Here is the call graph for this function:

◆ setData() [4/7]

void GLTexture2D::setData ( const std::vector< GLhalf > & data)

Upload 16-bit half-float data using previously set dimensions.

Parameters
dataInterleaved half-float pixels of size getSize().

◆ setData() [5/7]

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.

Parameters
dataInterleaved half-float pixels (GLhalf) of size componentCount*width*height.
widthWidth in texels.
heightHeight in texels.
componentCountComponents per texel (default 4 = RGBA).
Exceptions
GLExceptionif sizes do not match.
Here is the call graph for this function:

◆ setData() [6/7]

void GLTexture2D::setData ( const std::vector< GLubyte > & data)

Upload unsigned-byte data using previously set dimensions.

Parameters
dataInterleaved pixel bytes of size getSize().
Here is the call graph for this function:

◆ setData() [7/7]

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.

Parameters
dataInterleaved pixel bytes of size componentCount*width*height.
widthWidth in texels.
heightHeight in texels.
componentCountComponents per texel (default 4 = RGBA).
Exceptions
GLExceptionif sizes do not match.
Here is the call graph for this function:

◆ setEmpty()

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.

Parameters
widthWidth in texels.
heightHeight in texels.
componentCountComponents per texel (1..4).
dataTypeElement type (BYTE/HALF/FLOAT).
Postcondition
Internal storage is allocated and initialized to zeros.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFilter()

void GLTexture2D::setFilter ( GLint magFilter,
GLint minFilter )

Update filtering parameters on the bound texture.

Parameters
magFilterGL magnification filter.
minFilterGL minification filter.
Here is the caller graph for this function:

◆ setPixel()

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.

Parameters
dataBytes for one texel (size = componentCount).
xX coordinate (0..width-1).
yY coordinate (0..height-1).

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