Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::Shader Class Reference

A class to represent an OpenGL shader (vertex, fragment, etc.). More...

#include <shader.hpp>

Public Member Functions

 Shader ()=default
 Default constructor for Shader.
 
 ~Shader ()
 Destructor for Shader.
 
 MOVABLE_BUT_NOT_COPYABLE (Shader)
 Move constructor for Shader.
 
bool loadFromFile (const std::string &filePath, GLenum shaderType)
 Loads a shader from a file.
 
bool loadFromSource (const std::string &sourceCode, GLenum shaderType)
 Loads a shader from source code.
 
GLuint getID () const
 Gets the OpenGL shader ID.
 
const std::string & getLastError () const
 Gets the last error message.
 

Detailed Description

A class to represent an OpenGL shader (vertex, fragment, etc.).

This class provides functionality to load, compile, and manage OpenGL shader objects. It allows for loading shaders from source code or files, compiling them, and retrieving error information in case of compilation failures.

Definition at line 43 of file shader.hpp.

Constructor & Destructor Documentation

◆ ~Shader()

Raftel::Shader::~Shader ( )

Destructor for Shader.

Deletes the shader if it was created successfully.

Member Function Documentation

◆ getID()

GLuint Raftel::Shader::getID ( ) const
inline

Gets the OpenGL shader ID.

Returns
The shader ID.

Definition at line 88 of file shader.hpp.

◆ getLastError()

const std::string & Raftel::Shader::getLastError ( ) const
inline

Gets the last error message.

Returns
The error message.

Definition at line 95 of file shader.hpp.

◆ loadFromFile()

bool Raftel::Shader::loadFromFile ( const std::string & filePath,
GLenum shaderType )

Loads a shader from a file.

Parameters
filePathThe path to the shader file.
shaderTypeThe type of shader (GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc.).
Returns
True if the shader was successfully loaded, false otherwise.

◆ loadFromSource()

bool Raftel::Shader::loadFromSource ( const std::string & sourceCode,
GLenum shaderType )

Loads a shader from source code.

Parameters
sourceCodeThe source code of the shader.
shaderTypeThe type of shader (GL_VERTEX_SHADER, GL_FRAGMENT_SHADER, etc.).
Returns
True if the shader was successfully loaded, false otherwise.

◆ MOVABLE_BUT_NOT_COPYABLE()

Raftel::Shader::MOVABLE_BUT_NOT_COPYABLE ( Shader )

Move constructor for Shader.

Moves the resources of another Shader to this one.

Parameters
otherThe Shader to move from.

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