|
iridescence
|
GLSLShader is a wrapper for OpenGL shader programs. More...
#include <glsl_shader.hpp>
Public Member Functions | |
| GLSLShader () | |
| ~GLSLShader () | |
| bool | attach_source (const std::string &filename, GLuint shader_type) |
| bool | attach_source (const std::vector< std::string > &filenames, GLuint shader_type) |
| bool | attach_source (const std::string &filename, const std::unordered_set< std::string > &include_filenames, const std::string &defines, GLuint shader_type) |
| bool | attach_source (const std::vector< std::string > &filenames, const std::unordered_set< std::string > &include_filenames, const std::string &defines, GLuint shader_type) |
| bool | attach_source (const std::string &filename, const std::unordered_set< std::string > &include_filenames, const std::string &defines, const std::vector< std::pair< std::string, std::string > > &replaces, GLuint shader_type) |
| bool | attach_source (const std::vector< std::string > &filenames, const std::unordered_set< std::string > &include_filenames, const std::string &defines, const std::vector< std::pair< std::string, std::string > > &replaces, GLuint shader_type) |
| Attach shader source code from multiple files, with optional include files, defines, and replacements. | |
| bool | attach_source_code (const std::string &source_code, GLuint shader_type) |
| Attach shader source code from a string. | |
| bool | add_feedback_varying (const std::string &name) |
| bool | link_program () |
| Link attached shaders into a shader program. | |
| bool | init (const std::string &shader_path) |
| bool | init (const std::string &vertex_shader_path, const std::string &fragment_shader_path) |
| bool | init (const std::vector< std::string > &vertex_shader_paths, const std::vector< std::string > &fragment_shader_paths) |
| GLuint | id () const |
| Returns shader ID. | |
| void | use () const |
| Use the shader in the OpenGL context. | |
| void | unuse () const |
| Unuse the shader. | |
| GLint | attrib (std::uint64_t name, const char *debug_msg=nullptr) |
| GLint | attrib (const std::string &name) |
| GLint | uniform (std::uint64_t name, const char *debug_msg=nullptr) |
| GLint | uniform (const std::string &name) |
| GLint | subroutine (GLenum shader_type, std::uint64_t name, const char *debug_msg=nullptr) |
| GLint | subroutine (GLenum shader_type, const std::string &name) |
| GLint | subroutine_uniform (GLenum shader_type, std::uint64_t name, const char *debug_msg=nullptr) |
| GLint | subroutine_uniform (GLenum shader_type, const std::string &name) |
| int | get_uniformi (std::uint64_t name) |
| int | get_uniformi (const std::string &name) |
| float | get_uniformf (std::uint64_t name) |
| float | get_uniformf (const std::string &name) |
| Eigen::Vector4f | get_uniform4f (std::uint64_t name) |
| Eigen::Vector4f | get_uniform4f (const std::string &name) |
| Eigen::Matrix4f | get_uniform_matrix4f (std::uint64_t name) |
| Eigen::Matrix4f | get_uniform_matrix4f (const std::string &name) |
| void | copy_cached_uniforms (GLSLShader &other) const |
| template<typename T> | |
| T | get_uniform_cache (std::uint64_t name) const |
| template<typename T> | |
| std::optional< T > | get_uniform_cache_safe (std::uint64_t name) const |
| void | set_uniform (std::uint64_t name, int value, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, int value) |
| void | set_uniform (std::uint64_t name, float value, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, float value) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector2f &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector2f &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector3f &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector3f &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector4f &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector4f &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector2i &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector2i &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector3i &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector3i &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Vector4i &vector, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Vector4i &vector) |
| void | set_uniform (std::uint64_t name, const Eigen::Matrix4f &matrix, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Matrix4f &matrix) |
| void | set_uniform (std::uint64_t name, const std::vector< int > &vectors, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const std::vector< int > &vectors) |
| void | set_uniform (std::uint64_t name, const std::vector< float > &vectors, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const std::vector< float > &vectors) |
| void | set_uniform (std::uint64_t name, const std::vector< Eigen::Vector2f > &vectors, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const std::vector< Eigen::Vector2f > &vectors) |
| void | set_uniform (std::uint64_t name, const std::vector< Eigen::Vector3f > &vectors, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const std::vector< Eigen::Vector3f > &vectors) |
| void | set_uniform (std::uint64_t name, const std::vector< Eigen::Vector4f > &vectors, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const std::vector< Eigen::Vector4f > &vectors) |
| void | set_uniform (std::uint64_t name, const Eigen::Matrix4d &matrix_, const char *debug_msg=nullptr) |
| void | set_uniform (const std::string &name, const Eigen::Matrix4d &matrix_) |
| void | set_subroutine (GLenum shader_type, const std::string &loc, const std::string &func) |
GLSLShader is a wrapper for OpenGL shader programs.
Building a shader program — Option 1: From source files — auto shader = std::make_shared<glk::GLSLShader>(); shader->attach_source("vertex_shader.glsl", GL_VERTEX_SHADER); shader->attach_source("fragment_shader.glsl", GL_FRAGMENT_SHADER); shader->link_program(); — Option 2: From source files — std::string vs_source = "..."; // Vertex shader source code std::string fs_source = "..."; // Fragment shader source code shader->attach_source(vs_source, GL_VERTEX_SHADER); shader->attach_source(fs_source, GL_FRAGMENT_SHADER); shader->link_program();
shader->use(); GLint position_loc = shader->attrib("position"); GLint color_loc = shader->attrib("color"); GLint model_matrix_loc = shader->uniform("model_matrix");
| glk::GLSLShader::GLSLShader | ( | ) |
| glk::GLSLShader::~GLSLShader | ( | ) |
| bool glk::GLSLShader::add_feedback_varying | ( | const std::string & | name | ) |
| bool glk::GLSLShader::attach_source | ( | const std::string & | filename, |
| const std::unordered_set< std::string > & | include_filenames, | ||
| const std::string & | defines, | ||
| const std::vector< std::pair< std::string, std::string > > & | replaces, | ||
| GLuint | shader_type ) |
| bool glk::GLSLShader::attach_source | ( | const std::string & | filename, |
| const std::unordered_set< std::string > & | include_filenames, | ||
| const std::string & | defines, | ||
| GLuint | shader_type ) |
| bool glk::GLSLShader::attach_source | ( | const std::string & | filename, |
| GLuint | shader_type ) |
| bool glk::GLSLShader::attach_source | ( | const std::vector< std::string > & | filenames, |
| const std::unordered_set< std::string > & | include_filenames, | ||
| const std::string & | defines, | ||
| const std::vector< std::pair< std::string, std::string > > & | replaces, | ||
| GLuint | shader_type ) |
Attach shader source code from multiple files, with optional include files, defines, and replacements.
| filenames | Filenames of the shader source files to attach. |
| include_filenames | Filenames of the include files to be inserted into the shader source code. |
| defines | Preprocessor definitions to be added to the shader source code. |
| replaces | Pairs of strings representing text replacements to be made in the shader source code. |
| shader_type | Type of shader (e.g., GL_VERTEX_SHADER, GL_FRAGMENT_SHADER). |
| bool glk::GLSLShader::attach_source | ( | const std::vector< std::string > & | filenames, |
| const std::unordered_set< std::string > & | include_filenames, | ||
| const std::string & | defines, | ||
| GLuint | shader_type ) |
| bool glk::GLSLShader::attach_source | ( | const std::vector< std::string > & | filenames, |
| GLuint | shader_type ) |
| bool glk::GLSLShader::attach_source_code | ( | const std::string & | source_code, |
| GLuint | shader_type ) |
Attach shader source code from a string.
| source_code | Source code text |
| shader_type | Type of shader |
| GLint glk::GLSLShader::attrib | ( | const std::string & | name | ) |
| GLint glk::GLSLShader::attrib | ( | std::uint64_t | name, |
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::copy_cached_uniforms | ( | GLSLShader & | other | ) | const |
| Eigen::Vector4f glk::GLSLShader::get_uniform4f | ( | const std::string & | name | ) |
| Eigen::Vector4f glk::GLSLShader::get_uniform4f | ( | std::uint64_t | name | ) |
|
inline |
|
inline |
| Eigen::Matrix4f glk::GLSLShader::get_uniform_matrix4f | ( | const std::string & | name | ) |
| Eigen::Matrix4f glk::GLSLShader::get_uniform_matrix4f | ( | std::uint64_t | name | ) |
| float glk::GLSLShader::get_uniformf | ( | const std::string & | name | ) |
| float glk::GLSLShader::get_uniformf | ( | std::uint64_t | name | ) |
| int glk::GLSLShader::get_uniformi | ( | const std::string & | name | ) |
| int glk::GLSLShader::get_uniformi | ( | std::uint64_t | name | ) |
| GLuint glk::GLSLShader::id | ( | ) | const |
Returns shader ID.
| bool glk::GLSLShader::init | ( | const std::string & | shader_path | ) |
| bool glk::GLSLShader::init | ( | const std::string & | vertex_shader_path, |
| const std::string & | fragment_shader_path ) |
| bool glk::GLSLShader::init | ( | const std::vector< std::string > & | vertex_shader_paths, |
| const std::vector< std::string > & | fragment_shader_paths ) |
| bool glk::GLSLShader::link_program | ( | ) |
Link attached shaders into a shader program.
| void glk::GLSLShader::set_subroutine | ( | GLenum | shader_type, |
| const std::string & | loc, | ||
| const std::string & | func ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Matrix4d & | matrix_ ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Matrix4f & | matrix ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector2f & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector2i & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector3f & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector3i & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector4f & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const Eigen::Vector4i & | vector ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const std::vector< Eigen::Vector2f > & | vectors ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const std::vector< Eigen::Vector3f > & | vectors ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const std::vector< Eigen::Vector4f > & | vectors ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const std::vector< float > & | vectors ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| const std::vector< int > & | vectors ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| float | value ) |
| void glk::GLSLShader::set_uniform | ( | const std::string & | name, |
| int | value ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Matrix4d & | matrix_, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Matrix4f & | matrix, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector2f & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector2i & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector3f & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector3i & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector4f & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const Eigen::Vector4i & | vector, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const std::vector< Eigen::Vector2f > & | vectors, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const std::vector< Eigen::Vector3f > & | vectors, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const std::vector< Eigen::Vector4f > & | vectors, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const std::vector< float > & | vectors, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| const std::vector< int > & | vectors, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| float | value, | ||
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::set_uniform | ( | std::uint64_t | name, |
| int | value, | ||
| const char * | debug_msg = nullptr ) |
| GLint glk::GLSLShader::subroutine | ( | GLenum | shader_type, |
| const std::string & | name ) |
| GLint glk::GLSLShader::subroutine | ( | GLenum | shader_type, |
| std::uint64_t | name, | ||
| const char * | debug_msg = nullptr ) |
| GLint glk::GLSLShader::subroutine_uniform | ( | GLenum | shader_type, |
| const std::string & | name ) |
| GLint glk::GLSLShader::subroutine_uniform | ( | GLenum | shader_type, |
| std::uint64_t | name, | ||
| const char * | debug_msg = nullptr ) |
| GLint glk::GLSLShader::uniform | ( | const std::string & | name | ) |
| GLint glk::GLSLShader::uniform | ( | std::uint64_t | name, |
| const char * | debug_msg = nullptr ) |
| void glk::GLSLShader::unuse | ( | ) | const |
Unuse the shader.
| void glk::GLSLShader::use | ( | ) | const |
Use the shader in the OpenGL context.