|
mousetrap v0.2.0
|
shader, holds the OpenGL shader program, a vertex and a fragment shader More...
#include <shader.hpp>
Public Member Functions | |
| Shader () | |
| construct, holds default shader program for both fragment and vertex | |
| ~Shader () | |
| destruct, frees GPU-side memory | |
| Shader (detail::ShaderInternal *) | |
| construct from internal \for_internal_use_only | |
| NativeObject | get_internal () const override |
| expose internal | |
| operator NativeObject () const override | |
| expose as GObject \for_internal_use_only | |
| GLNativeHandle | get_program_id () const |
| get the native OpenGL id of the shader program | |
| GLNativeHandle | get_fragment_shader_id () const |
| get the native OpenGL id of the fragment shader | |
| GLNativeHandle | get_vertex_shader_id () const |
| get the native OpenGL id of the vertex shader | |
| bool | create_from_string (ShaderType type, const std::string &code) |
| create shader from source code as string | |
| bool | create_from_file (ShaderType type, const std::string &path) |
| create shader from a file, usually .glsl, .frag or .vert | |
| int | get_uniform_location (const std::string &name) const |
| get location of a uniform with given name | |
| void | set_uniform_float (const std::string &uniform_name, float) const |
| set uniform float | |
| void | set_uniform_int (const std::string &uniform_name, int) const |
| set uniform int | |
| void | set_uniform_uint (const std::string &uniform_name, glm::uint) const |
| set uniform uint | |
| void | set_uniform_vec2 (const std::string &uniform_name, Vector2f) const |
| set uniform vec2 | |
| void | set_uniform_vec3 (const std::string &uniform_name, Vector3f) const |
| set uniform vec3 | |
| void | set_uniform_vec4 (const std::string &uniform_name, Vector4f) const |
| set uniform vec4 | |
| void | set_uniform_transform (const std::string &uniform_name, GLTransform) const |
| set uniform mat4x4 | |
Public Member Functions inherited from mousetrap::SignalEmitter | |
| void | set_signal_blocked (const std::string &signal_id, bool b) |
| block a signal by id \for_internal_use_only | |
| bool | get_signal_blocked (const std::string &signal_id) const |
| get whether a signal is currently blocked | |
| std::vector< std::string > | get_all_signal_names () |
| get list of possible signal ids \for_internal_use_only | |
| template<typename Function_t > | |
| void | connect_signal (const std::string &signal_id, Function_t *function, void *data=nullptr) |
| connect static function to signal, does not work with lambdas \for_internal_use_only | |
| void | disconnect_signal (const std::string &signal_id) |
| disconnect signal, it may not be invoked until reconnected, if signal is not registered, does nothing. For internal use only | |
| virtual | operator NativeObject () const =0 |
| expose as NativeObject, this is the GLib instance that signals are emitted on \for_internal_use_only | |
| virtual NativeObject | get_internal () const |
| expose internally managed object, \for_internal_use_only | |
Static Public Member Functions | |
| static int | get_vertex_position_location () |
get position of the default _vertex_position uniform | |
| static int | get_vertex_color_location () |
get position of the default _vertex_color uniform | |
| static int | get_vertex_texture_coordinate_location () |
get position of the default _texture_coordinates uniform | |
Static Public Attributes | |
| static const std::string | noop_fragment_shader_code |
| default fragment shader behavior, render a shape respecting its vertices colors and its optional texture | |
| static const std::string | noop_vertex_shader_code |
| noop vertex shader behavior, render the shapes vertices after applying the set transform | |
Additional Inherited Members | |
Protected Member Functions inherited from mousetrap::SignalEmitter | |
| SignalEmitter () | |
| ctor | |
| ~SignalEmitter () | |
| destructor | |
shader, holds the OpenGL shader program, a vertex and a fragment shader
| bool mousetrap::Shader::create_from_file | ( | ShaderType | type, |
| const std::string & | path | ||
| ) |
create shader from a file, usually .glsl, .frag or .vert
| type | One of ShaderType::FRAGMENT or ShaderType::VERTEX |
| path | absolute path to file with glsl code |
References create_from_string(), and mousetrap::log::critical().
| bool mousetrap::Shader::create_from_string | ( | ShaderType | type, |
| const std::string & | code | ||
| ) |
create shader from source code as string
| type | One of ShaderType::FRAGMENT or ShaderType::VERTEX |
| code | glsl code |
Referenced by create_from_file().
| GLNativeHandle mousetrap::Shader::get_fragment_shader_id | ( | ) | const |
get the native OpenGL id of the fragment shader
|
overridevirtual |
expose internal
Reimplemented from mousetrap::SignalEmitter.
| GLNativeHandle mousetrap::Shader::get_program_id | ( | ) | const |
get the native OpenGL id of the shader program
Referenced by get_uniform_location(), mousetrap::Shape::render(), set_uniform_float(), set_uniform_int(), set_uniform_transform(), set_uniform_uint(), set_uniform_vec2(), set_uniform_vec3(), and set_uniform_vec4().
| int mousetrap::Shader::get_uniform_location | ( | const std::string & | name | ) | const |
get location of a uniform with given name
| name | exact name of a uniform mentioned in the shader source code |
References get_program_id().
Referenced by mousetrap::Shape::render(), set_uniform_float(), set_uniform_int(), set_uniform_transform(), set_uniform_uint(), set_uniform_vec2(), set_uniform_vec3(), and set_uniform_vec4().
|
static |
get position of the default _vertex_color uniform
|
static |
get position of the default _vertex_position uniform
| GLNativeHandle mousetrap::Shader::get_vertex_shader_id | ( | ) | const |
get the native OpenGL id of the vertex shader
|
static |
get position of the default _texture_coordinates uniform
|
overridevirtual |
expose as GObject \for_internal_use_only
Implements mousetrap::SignalEmitter.
| void mousetrap::Shader::set_uniform_float | ( | const std::string & | uniform_name, |
| float | value | ||
| ) | const |
set uniform float
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
| void mousetrap::Shader::set_uniform_int | ( | const std::string & | uniform_name, |
| int | value | ||
| ) | const |
set uniform int
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
| void mousetrap::Shader::set_uniform_transform | ( | const std::string & | uniform_name, |
| GLTransform | value | ||
| ) | const |
set uniform mat4x4
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), get_uniform_location(), and mousetrap::GLTransform::transform.
| void mousetrap::Shader::set_uniform_uint | ( | const std::string & | uniform_name, |
| glm::uint | value | ||
| ) | const |
set uniform uint
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
| void mousetrap::Shader::set_uniform_vec2 | ( | const std::string & | uniform_name, |
| Vector2f | value | ||
| ) | const |
set uniform vec2
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
| void mousetrap::Shader::set_uniform_vec3 | ( | const std::string & | uniform_name, |
| Vector3f | value | ||
| ) | const |
set uniform vec3
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
| void mousetrap::Shader::set_uniform_vec4 | ( | const std::string & | uniform_name, |
| Vector4f | value | ||
| ) | const |
set uniform vec4
| uniform_name | exact name of a uniform mentioned in the shader source |
| value |
References get_program_id(), and get_uniform_location().
|
inlinestatic |
default fragment shader behavior, render a shape respecting its vertices colors and its optional texture
Referenced by Shader().
|
inlinestatic |
noop vertex shader behavior, render the shapes vertices after applying the set transform
Referenced by Shader().