sgltk 0.6
Simple OpenGL Tool Kit
Loading...
Searching...
No Matches
sgltk::Texture Class Referenceabstract

Manages textures. More...

#include <texture.h>

Inheritance diagram for sgltk::Texture:

Public Member Functions

void set_parameter (GLenum name, int parameter)
 Sets a texture parameter.
void set_parameter (GLenum name, float parameter)
 Sets a texture parameter.
void set_parameter (GLenum name, float *parameter)
 Sets a texture parameter.
virtual void bind (unsigned int texture_unit=0)=0
 Bind the texture to be used by the shader.
virtual void unbind (unsigned int texture_unit=0)=0
 Unbind the texture.
void bind_image (GLuint unit, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)
 Binds a level of a texture to an image unit.

Static Public Member Functions

static void add_path (std::string path)
 Adds a path to the list of paths to be searched for image files.
static bool store_texture (std::string name, std::shared_ptr< Texture > texture)
 Stores a texture object in an internal map using the name parameter as key (no duplicates)
static std::shared_ptr< Texturefind_texture (std::string name)
 Finds a texture in the internal map using the name as key.

Public Attributes

GLenum target
 The texture target.
GLuint texture
 The texture name.
unsigned int width
 The width of the texture.
unsigned int height
 The height of the texture.
unsigned int num_layers
 The number of layers.

Detailed Description

Manages textures.

Definition at line 13 of file texture.h.

Constructor & Destructor Documentation

◆ Texture()

Texture::Texture ( )

Definition at line 7 of file texture.cpp.

◆ ~Texture()

Texture::~Texture ( )

Definition at line 14 of file texture.cpp.

Member Function Documentation

◆ add_path()

void Texture::add_path ( std::string path)
static

Adds a path to the list of paths to be searched for image files.

Parameters
pathThe path to add to the list
Note
To avoid duplicates this function first performs a search on existing entries.

Definition at line 47 of file texture.cpp.

◆ bind()

virtual void sgltk::Texture::bind ( unsigned int texture_unit = 0)
pure virtual

Bind the texture to be used by the shader.

Parameters
texture_unitThe texture unit to bind the texture to

Implemented in sgltk::Cubemap, sgltk::Texture_1d, sgltk::Texture_1d_Array, sgltk::Texture_2d, sgltk::Texture_2d_Array, and sgltk::Texture_3d.

◆ bind_image()

void Texture::bind_image ( GLuint unit,
GLint level,
GLboolean layered,
GLint layer,
GLenum access,
GLenum format )

Binds a level of a texture to an image unit.

Parameters
unitThe index of the image unit to which to bind the texture
levelThe level of the texture that is to be bound
layeredSpecifies whether a layered texture binding is to be established
layerIf layered is GL_FALSE, specifies the layer of texture to be bound to the image unit, ignored otherwise
accessSpecifies the type of access that will be performed on the image
formatSpecifies the format that the elements of the image will be treated as

Definition at line 51 of file texture.cpp.

◆ find_texture()

std::shared_ptr< Texture > Texture::find_texture ( std::string name)
static

Finds a texture in the internal map using the name as key.

Parameters
nameThe key used to find the texture
Returns
Returns a pointer to the found texture object or nullptr if no texture with such name could be found.

Definition at line 40 of file texture.cpp.

◆ set_parameter() [1/3]

void Texture::set_parameter ( GLenum name,
float * parameter )

Sets a texture parameter.

Parameters
nameThe name of the texture parameter
parameterThe parameter value

Definition at line 30 of file texture.cpp.

◆ set_parameter() [2/3]

void Texture::set_parameter ( GLenum name,
float parameter )

Sets a texture parameter.

Parameters
nameThe name of the texture parameter
parameterThe parameter value

Definition at line 24 of file texture.cpp.

◆ set_parameter() [3/3]

void Texture::set_parameter ( GLenum name,
int parameter )

Sets a texture parameter.

Parameters
nameThe name of the texture parameter
parameterThe parameter value

Definition at line 18 of file texture.cpp.

◆ store_texture()

bool Texture::store_texture ( std::string name,
std::shared_ptr< Texture > texture )
static

Stores a texture object in an internal map using the name parameter as key (no duplicates)

Parameters
nameThe key used to store the texture
textureThe texture to be stored
Returns
Returns true if the insertion was successful, false otherwise

Definition at line 36 of file texture.cpp.

◆ unbind()

virtual void sgltk::Texture::unbind ( unsigned int texture_unit = 0)
pure virtual

Unbind the texture.

Parameters
texture_unitThe texture unit to bind the texture to

Implemented in sgltk::Cubemap, sgltk::Texture_1d, sgltk::Texture_1d_Array, sgltk::Texture_2d, sgltk::Texture_2d_Array, and sgltk::Texture_3d.

Member Data Documentation

◆ height

unsigned int sgltk::Texture::height

The height of the texture.

Definition at line 42 of file texture.h.

◆ num_layers

unsigned int sgltk::Texture::num_layers

The number of layers.

Definition at line 46 of file texture.h.

◆ target

GLenum sgltk::Texture::target

The texture target.

Definition at line 30 of file texture.h.

◆ texture

GLuint sgltk::Texture::texture

The texture name.

Definition at line 34 of file texture.h.

◆ width

unsigned int sgltk::Texture::width

The width of the texture.

Definition at line 38 of file texture.h.


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