Easy3D 2.6.1
Loading...
Searching...
No Matches
ShaderManager Class Reference

Management of shader programs. More...

#include <easy3d/renderer/shader_manager.h>

Static Public Member Functions

static ShaderProgramget_program (const std::string &shader_name)
 Get the shader program if it exists and is working.
 
static ShaderProgramcreate_program_from_files (const std::string &file_base_name, const std::vector< ShaderProgram::Attribute > &attributes=std::vector< ShaderProgram::Attribute >(), const std::vector< std::string > &outputs=std::vector< std::string >(), bool geom_shader=false)
 Create a shader program from shader source files specified by the shader file's base name.
 
static ShaderProgramcreate_program_from_files (const std::string &vert_file_name, const std::string &frag_file_name, const std::string &geom_file_name="", const std::string &extra_vert_code="", const std::string &extra_frag_code="", const std::string &extra_geom_code="", const std::vector< ShaderProgram::Attribute > &attributes=std::vector< ShaderProgram::Attribute >(), const std::vector< std::string > &outputs=std::vector< std::string >())
 Create a shader program from shader source files specified by individual file names.
 
static ShaderProgramcreate_program_from_codes (const std::string &vert_code, const std::string &frag_code, const std::string &geom_code="", const std::vector< ShaderProgram::Attribute > &attributes=std::vector< ShaderProgram::Attribute >(), const std::vector< std::string > &outputs=std::vector< std::string >())
 Create a shader program from completed shader source codes.
 
static std::vector< ShaderProgram * > all_programs ()
 Get all shader programs.
 
static void terminate ()
 Destroy all shader programs.
 
static void reload ()
 Reload all shader programs.
 

Detailed Description

Management of shader programs.

Note
Make sure to call terminate() to destroy existing programs before the OpenGL context is deleted.

Member Function Documentation

◆ all_programs()

std::vector< ShaderProgram * > all_programs ( )
static

Get all shader programs.

Returns
A vector of all shader programs.

◆ create_program_from_codes()

ShaderProgram * create_program_from_codes ( const std::string & vert_code,
const std::string & frag_code,
const std::string & geom_code = "",
const std::vector< ShaderProgram::Attribute > & attributes = std::vector<ShaderProgram::Attribute>(),
const std::vector< std::string > & outputs = std::vector<std::string>() )
static

Create a shader program from completed shader source codes.

Parameters
vert_codeThe vertex shader code.
frag_codeThe fragment shader code.
geom_codeThe geometry shader code (optional).
attributesThe attributes for the shader program.
outputsThe outputs for the shader program.
Returns
The created shader program.

◆ create_program_from_files() [1/2]

ShaderProgram * create_program_from_files ( const std::string & file_base_name,
const std::vector< ShaderProgram::Attribute > & attributes = std::vector<ShaderProgram::Attribute>(),
const std::vector< std::string > & outputs = std::vector<std::string>(),
bool geom_shader = false )
static

Create a shader program from shader source files specified by the shader file's base name.

Parameters
file_base_nameThe base name of the shader files.
attributesThe attributes for the shader program.
outputsThe outputs for the shader program.
geom_shaderTrue if a geometry shader is included.
Returns
The created shader program.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp, and Tutorial_204_Viewer_Qt/main.cpp.

◆ create_program_from_files() [2/2]

ShaderProgram * create_program_from_files ( const std::string & vert_file_name,
const std::string & frag_file_name,
const std::string & geom_file_name = "",
const std::string & extra_vert_code = "",
const std::string & extra_frag_code = "",
const std::string & extra_geom_code = "",
const std::vector< ShaderProgram::Attribute > & attributes = std::vector<ShaderProgram::Attribute>(),
const std::vector< std::string > & outputs = std::vector<std::string>() )
static

Create a shader program from shader source files specified by individual file names.

Parameters
vert_file_nameThe vertex shader file name.
frag_file_nameThe fragment shader file name.
geom_file_nameThe geometry shader file name (optional).
extra_vert_codeExtra vertex shader code (optional).
extra_frag_codeExtra fragment shader code (optional).
extra_geom_codeExtra geometry shader code (optional).
attributesThe attributes for the shader program.
outputsThe outputs for the shader program.
Returns
The created shader program.

◆ get_program()

ShaderProgram * get_program ( const std::string & shader_name)
static

Get the shader program if it exists and is working.

Parameters
shader_nameThe base name of the program's source file.
Returns
The shader program if it exists and is working, otherwise nullptr.
Examples
Tutorial_203_Viewer_wxWidgets/main.cpp, and Tutorial_204_Viewer_Qt/main.cpp.

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