SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
sgct::ShaderManager Class Reference

For managing shader programs. More...

#include <sgct/shadermanager.h>

Public Member Functions

 ShaderManager (const ShaderManager &)=delete
 ShaderManager (ShaderManager &&)=delete
ShaderManager & operator= (const ShaderManager &)=delete
ShaderManager & operator= (ShaderManager &&)=delete
 ~ShaderManager ()
 Destructor deallocates and deletes all shaders.
void addShaderProgram (std::string name, std::string_view vertexSrc, std::string_view fragmentSrc)
 Adds shader programs to the manager.
bool removeShaderProgram (std::string_view name)
 Removes a shader program from the manager.
bool shaderProgramExists (std::string_view name) const
 Check if a shader program exists in the manager.
const ShaderProgram & shaderProgram (std::string_view name) const
 Get the specified shader program from the shader manager.

Static Public Member Functions

static ShaderManager & instance ()
static void destroy ()

Detailed Description

For managing shader programs.

Implemented as a singleton.

Constructor & Destructor Documentation

◆ ShaderManager() [1/2]

sgct::ShaderManager::ShaderManager ( const ShaderManager & )
delete

◆ ShaderManager() [2/2]

sgct::ShaderManager::ShaderManager ( ShaderManager && )
delete

◆ ~ShaderManager()

sgct::ShaderManager::~ShaderManager ( )

Destructor deallocates and deletes all shaders.

Member Function Documentation

◆ addShaderProgram()

void sgct::ShaderManager::addShaderProgram ( std::string name,
std::string_view vertexSrc,
std::string_view fragmentSrc )

Adds shader programs to the manager.

The shaders will be compiled and linked to the program. The name of the shader needs to be unique or it won't be added and an exception is thrown. Both vertex shader and fragment shader source need to be provided, either as a link to a shader source code file or as shader source code.

Parameters
nameUnique name of the shader
vertexSrcThe vertex shader source code
fragmentSrcThe fragment shader source code
Exceptions
std::runtime_errorIf there was an error creating the shader program

◆ destroy()

void sgct::ShaderManager::destroy ( )
static

◆ instance()

ShaderManager & sgct::ShaderManager::instance ( )
static

◆ operator=() [1/2]

ShaderManager & sgct::ShaderManager::operator= ( const ShaderManager & )
delete

◆ operator=() [2/2]

ShaderManager & sgct::ShaderManager::operator= ( ShaderManager && )
delete

◆ removeShaderProgram()

bool sgct::ShaderManager::removeShaderProgram ( std::string_view name)

Removes a shader program from the manager.

All resources allocated for the program will be deallocated and removed.

Parameters
nameName of the shader program to remove
Returns
true if the shader program was removed correctly

◆ shaderProgram()

const ShaderProgram & sgct::ShaderManager::shaderProgram ( std::string_view name) const

Get the specified shader program from the shader manager.

Parameters
nameName of the shader program
Returns
The specified shader program
Exceptions
std::runtime_errorIf the shader program with the name was not found

◆ shaderProgramExists()

bool sgct::ShaderManager::shaderProgramExists ( std::string_view name) const

Check if a shader program exists in the manager.

Parameters
nameName of the shader program

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