matf-rg-engine 1.0.0
Base for project for the Computer Graphics course at Faculty of Mathematics, University of Belgrade
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
engine::resources::Texture Class Reference

Represents a texture object within the OpenGL context. More...

#include <Texture.hpp>

Public Member Functions

void destroy ()
 Destroys the texture object in the OpenGL context.
 
TextureType type () const
 Returns the type of the texture.
 
uint32_t id () const
 Returns the OpenGL ID of the texture.
 
void bind (int32_t sampler)
 Binds the texture to a given sampler.
 
const std::filesystem::path & path () const
 Returns the path to the texture file from which the texture was loaded.
 
const std::string & name () const
 Returns the name of the texture by which it can be referenced using the engine::resources::ResourcesController::texture function.
 
 Texture ()=default
 

Static Public Member Functions

static std::string_view uniform_name_convention (TextureType type)
 Returns the uniform name convention for a given texture type. The convention is used by the Model class to bind the texture to the correct uniform sampler by name.
 

Private Member Functions

 Texture (uint32_t id, TextureType type, std::filesystem::path path, std::string name)
 Constructs a Texture object.
 

Private Attributes

uint32_t m_id {}
 
TextureType m_type {}
 
std::filesystem::path m_path {}
 
std::string m_name {}
 

Friends

class ResourcesController
 

Detailed Description

Represents a texture object within the OpenGL context.

Constructor & Destructor Documentation

◆ Texture() [1/2]

engine::resources::Texture::Texture ( )
default

◆ Texture() [2/2]

engine::resources::Texture::Texture ( uint32_t  id,
TextureType  type,
std::filesystem::path  path,
std::string  name 
)
inlineprivate

Constructs a Texture object.

Parameters
idThe OpenGL ID of the texture.
typeThe type of the texture.
pathThe path to the texture file.
nameThe name of the texture.

Member Function Documentation

◆ uniform_name_convention()

std::string_view engine::resources::Texture::uniform_name_convention ( TextureType  type)
static

Returns the uniform name convention for a given texture type. The convention is used by the Model class to bind the texture to the correct uniform sampler by name.

Parameters
typeThe type of the texture.
Returns
The uniform name convention for the texture type.
// #shader fragment
uniform sampler2D texture_diffuse;
...
void main() {
gl_FragColor = texture(texture_diffuse, uv);
}
int main(int argc, char **argv)
Definition TestApp.cpp:14

◆ destroy()

void engine::resources::Texture::destroy ( )

Destroys the texture object in the OpenGL context.

◆ type()

TextureType engine::resources::Texture::type ( ) const
inline

Returns the type of the texture.

Returns
The type of the texture.

◆ id()

uint32_t engine::resources::Texture::id ( ) const
inline

Returns the OpenGL ID of the texture.

Returns
The OpenGL ID of the texture.

◆ bind()

void engine::resources::Texture::bind ( int32_t  sampler)

Binds the texture to a given sampler.

Parameters
samplerThe sampler to bind the texture to.

◆ path()

const std::filesystem::path & engine::resources::Texture::path ( ) const
inline

Returns the path to the texture file from which the texture was loaded.

Returns
The path to the texture file.

◆ name()

const std::string & engine::resources::Texture::name ( ) const
inline

Returns the name of the texture by which it can be referenced using the engine::resources::ResourcesController::texture function.

Returns
The name of the texture.

Friends And Related Symbol Documentation

◆ ResourcesController

friend class ResourcesController
friend

Member Data Documentation

◆ m_id

uint32_t engine::resources::Texture::m_id {}
private

◆ m_type

TextureType engine::resources::Texture::m_type {}
private

◆ m_path

std::filesystem::path engine::resources::Texture::m_path {}
private

◆ m_name

std::string engine::resources::Texture::m_name {}
private

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