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 | Private Member Functions | Private Attributes | Friends | List of all members
engine::resources::Shader Class Reference

Represents a linked shader program object within the OpenGL context. More...

#include <Shader.hpp>

Public Member Functions

void use () const
 Binds the shader program.
 
unsigned id () const
 Returns the OpenGL ID of the shader program.
 
void set_bool (const std::string &name, bool value) const
 Sets a boolean uniform value.
 
void set_int (const std::string &name, int value) const
 Sets an integer uniform value.
 
void set_float (const std::string &name, float value) const
 Sets a float uniform value.
 
void set_vec2 (const std::string &name, const glm::vec2 &value) const
 Sets a 2D vector uniform value.
 
void set_vec3 (const std::string &name, const glm::vec3 &value) const
 Sets a 3D vector uniform value.
 
void set_vec4 (const std::string &name, const glm::vec4 &value) const
 Sets a 4D vector uniform value.
 
void set_mat2 (const std::string &name, const glm::mat2 &mat) const
 Sets a 2x2 matrix uniform value.
 
void set_mat3 (const std::string &name, const glm::mat3 &mat) const
 Sets a 3x3 matrix uniform value.
 
void set_mat4 (const std::string &name, const glm::mat4 &mat) const
 Sets a 4x4 matrix uniform value.
 
const std::string & name () const
 Returns the name of the shader program by which it can be referenced using the engine::resources::ResourcesController::shader function.
 
const std::string & source () const
 Returns the source code of the shader program.
 
const std::filesystem::path & source_path () const
 Returns the path to the source file from which the shader program was compiled.
 

Private Member Functions

 Shader (unsigned shader_id, std::string name, std::string source, std::filesystem::path source_path="")
 Constructs a Shader object.
 
void destroy () const
 Destroys the shader program in the OpenGL context.
 

Private Attributes

unsigned m_shaderId
 The OpenGL ID of the shader program.
 
std::string m_name
 The name of the shader program.
 
std::string m_source
 
std::filesystem::path m_source_path
 

Friends

class ShaderCompiler
 

Detailed Description

Represents a linked shader program object within the OpenGL context.

Constructor & Destructor Documentation

◆ Shader()

engine::resources::Shader::Shader ( unsigned  shader_id,
std::string  name,
std::string  source,
std::filesystem::path  source_path = "" 
)
private

Constructs a Shader object.

Parameters
shader_idThe OpenGL ID of the shader program.
nameThe name of the shader program.
sourceThe source code of the shader program.
source_pathThe path to the source file from which the shader program was compiled.

Member Function Documentation

◆ use()

void engine::resources::Shader::use ( ) const

Binds the shader program.

◆ id()

unsigned engine::resources::Shader::id ( ) const

Returns the OpenGL ID of the shader program.

Returns
The OpenGL ID of the shader program.

◆ set_bool()

void engine::resources::Shader::set_bool ( const std::string &  name,
bool  value 
) const

Sets a boolean uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_int()

void engine::resources::Shader::set_int ( const std::string &  name,
int  value 
) const

Sets an integer uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_float()

void engine::resources::Shader::set_float ( const std::string &  name,
float  value 
) const

Sets a float uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_vec2()

void engine::resources::Shader::set_vec2 ( const std::string &  name,
const glm::vec2 &  value 
) const

Sets a 2D vector uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_vec3()

void engine::resources::Shader::set_vec3 ( const std::string &  name,
const glm::vec3 &  value 
) const

Sets a 3D vector uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_vec4()

void engine::resources::Shader::set_vec4 ( const std::string &  name,
const glm::vec4 &  value 
) const

Sets a 4D vector uniform value.

Parameters
nameThe name of the uniform.
valueThe value to set.

◆ set_mat2()

void engine::resources::Shader::set_mat2 ( const std::string &  name,
const glm::mat2 &  mat 
) const

Sets a 2x2 matrix uniform value.

Parameters
nameThe name of the uniform.
matThe value to set.

◆ set_mat3()

void engine::resources::Shader::set_mat3 ( const std::string &  name,
const glm::mat3 &  mat 
) const

Sets a 3x3 matrix uniform value.

Parameters
nameThe name of the uniform.
matThe value to set.

◆ set_mat4()

void engine::resources::Shader::set_mat4 ( const std::string &  name,
const glm::mat4 &  mat 
) const

Sets a 4x4 matrix uniform value.

Parameters
nameThe name of the uniform.
matThe value to set.

◆ name()

const std::string & engine::resources::Shader::name ( ) const

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

Returns
The name of the shader.

◆ source()

const std::string & engine::resources::Shader::source ( ) const

Returns the source code of the shader program.

Returns
The source code of the shader.

◆ source_path()

const std::filesystem::path & engine::resources::Shader::source_path ( ) const

Returns the path to the source file from which the shader program was compiled.

Returns
The path to the source file of the shader program.

◆ destroy()

void engine::resources::Shader::destroy ( ) const
private

Destroys the shader program in the OpenGL context.

Friends And Related Symbol Documentation

◆ ShaderCompiler

friend class ShaderCompiler
friend

Member Data Documentation

◆ m_shaderId

unsigned engine::resources::Shader::m_shaderId
private

The OpenGL ID of the shader program.

◆ m_name

std::string engine::resources::Shader::m_name
private

The name of the shader program.

◆ m_source

std::string engine::resources::Shader::m_source
private

◆ m_source_path

std::filesystem::path engine::resources::Shader::m_source_path
private

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