iridescence
Loading...
Searching...
No Matches
glk::Texture Class Reference

Texture class to wrap OpenGL texture object. More...

#include <texture.hpp>

Public Member Functions

 Texture (const Eigen::Vector2i &size, GLuint internal_format, GLuint format, GLuint type, const void *pixels=nullptr)
 Constructor.
 ~Texture ()
 Texture (const Texture &temp_obj)=delete
Texture & operator= (const Texture &temp_obj)=delete
GLuint id () const
 Texture ID.
Eigen::Vector2i size () const
 Texture size.
void set_size (const Eigen::Vector2i &size)
 Change the size of the texture. This will invalidate the texture data and change the texture ID.
void bind () const
 Bind the texture.
void bind (GLenum target) const
 Bind the texture to the specified target (e.g., GL_TEXTURE0).
void unbind () const
 Unbind the texture.
void unbind (GLenum target) const
 Unbind the texture from the specified target (e.g., GL_TEXTURE0).
const Texture & set_filer_mode (GLenum mode) const
 Set the filtering mode of the texture (e.g., GL_LINEAR, GL_NEAREST).
const Texture & set_clamp_mode (GLenum mode) const
 Set the clamping mode of the texture (e.g., GL_CLAMP_TO_EDGE, GL_REPEAT).
template<typename T>
std::vector< T > read_pixels (GLuint format=GL_RGBA, GLuint type=GL_UNSIGNED_BYTE, int num_elements=4) const
 Read the pixel data from the texture into a vector.

Detailed Description

Texture class to wrap OpenGL texture object.

Constructor & Destructor Documentation

◆ Texture() [1/2]

glk::Texture::Texture ( const Eigen::Vector2i & size,
GLuint internal_format,
GLuint format,
GLuint type,
const void * pixels = nullptr )

Constructor.

Note
Default filter mode is GL_LINEAR, and default clamp mode is GL_CLAMP_TO_EDGE.
Parameters
sizeSize (width, height)
internal_formatInternal format of the texture (e.g., GL_RGBA8)
formatFormat of the pixel data (e.g., GL_RGBA)
typeData type of the pixel data (e.g., GL_UNSIGNED_BYTE)
pixelsPointer to the pixel data. If nullptr, the texture is created but not initialized.

◆ ~Texture()

glk::Texture::~Texture ( )

◆ Texture() [2/2]

glk::Texture::Texture ( const Texture & temp_obj)
delete

Member Function Documentation

◆ bind() [1/2]

void glk::Texture::bind ( ) const

Bind the texture.

◆ bind() [2/2]

void glk::Texture::bind ( GLenum target) const

Bind the texture to the specified target (e.g., GL_TEXTURE0).

◆ id()

GLuint glk::Texture::id ( ) const

Texture ID.

◆ operator=()

Texture & glk::Texture::operator= ( const Texture & temp_obj)
delete

◆ read_pixels()

template<typename T>
std::vector< T > glk::Texture::read_pixels ( GLuint format = GL_RGBA,
GLuint type = GL_UNSIGNED_BYTE,
int num_elements = 4 ) const

Read the pixel data from the texture into a vector.

Template Parameters
TData type of the pixel data to read (uint8, uint16, int32, uint32, or float)
Parameters
formatFormat of the pixel data to read (e.g., GL_RGBA, GL_RGB, GL_RED)
typeData type of the pixel data to read (e.g., GL_UNSIGNED_BYTE, GL_FLOAT)
num_elementsNumber of elements per pixel (e.g., 4 for RGBA, 3 for RGB, 1 for RED)
Returns
Loaded pixel data.

◆ set_clamp_mode()

const Texture & glk::Texture::set_clamp_mode ( GLenum mode) const

Set the clamping mode of the texture (e.g., GL_CLAMP_TO_EDGE, GL_REPEAT).

◆ set_filer_mode()

const Texture & glk::Texture::set_filer_mode ( GLenum mode) const

Set the filtering mode of the texture (e.g., GL_LINEAR, GL_NEAREST).

◆ set_size()

void glk::Texture::set_size ( const Eigen::Vector2i & size)

Change the size of the texture. This will invalidate the texture data and change the texture ID.

◆ size()

Eigen::Vector2i glk::Texture::size ( ) const

Texture size.

◆ unbind() [1/2]

void glk::Texture::unbind ( ) const

Unbind the texture.

◆ unbind() [2/2]

void glk::Texture::unbind ( GLenum target) const

Unbind the texture from the specified target (e.g., GL_TEXTURE0).


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