gdk-graphics 0b051eb9b5c1eaa0658babaa4463dd7a80aa9d2c
Loading...
Searching...
No Matches
gdk::webgl1es2_shader_program Class Referencefinal

Specifies drawing behaviours at the two programmable stages in the OpenGL ES 2.0/WebGL 1.0 pipeline (the vertex shader stage and fragment shader stage) TODO: array uniform methods currently force the use of vectors. should add support for c-style arrays and std::arrays. More...

#include <webgl1es2_shader_program.h>

Inheritance diagram for gdk::webgl1es2_shader_program:
gdk::shader_program

Classes

struct  active_attribute_info
 index, size, type of an active attribute used in the shader program More...
 
struct  active_uniform_info
 index. size. type o an active uniform used in the shader program More...
 

Public Types

using active_attribute_collection_type = std::unordered_map<std::string, active_attribute_info>
 
using active_uniform_collection_type = std::unordered_map<std::string, active_uniform_info>
 
using integer2_uniform_type = graphics_intvector2_type
 type alias used for setting int2 uniform value
 
using integer3_uniform_type = graphics_intvector3_type
 type alias used for setting int3 uniform value
 
using integer4_uniform_type = graphics_intvector4_type
 type alias used for setting int4 uniform value
 

Public Member Functions

std::optional< active_attribute_infotryGetActiveAttribute (const std::string &aAttributeName) const
 returns a nonnull optional to an attribute info if one with the given name exists
 
bool try_set_uniform (const std::string &aName, const GLfloat aValue) const
 assign a float1 uniform from a float
 
bool try_set_uniform (const std::string &aName, const graphics_vector2_type &aValue) const
 assign a float2 uniform from a 2 component vector
 
bool try_set_uniform (const std::string &aName, const graphics_vector3_type &aValue) const
 assign a float3 uniform from a 3 component vector
 
bool try_set_uniform (const std::string &aName, const graphics_vector4_type &aValue) const
 assign a float4 uniform from a 4 component vector
 
bool try_set_uniform (const std::string &aName, const std::vector< GLfloat > &avalue) const
 assign a float uniform array from an array of floats
 
bool try_set_uniform (const std::string &aName, const std::vector< graphics_vector2_type > &avalue) const
 assign a float2 uniform array from an array of float2s
 
bool try_set_uniform (const std::string &aName, const std::vector< graphics_vector3_type > &avalue) const
 assign a value to a float3 uniform array from a vector of float3s
 
bool try_set_uniform (const std::string &aName, const std::vector< graphics_vector4_type > &avalue) const
 assign a value to a float4 uniform array from a vector of float4s
 
bool try_set_uniform (const std::string &aName, const GLint aValue) const
 assign a value to a integer uniform
 
bool try_set_uniform (const std::string aName, const integer2_uniform_type &aValue) const
 assign a value to a integer2 uniform
 
bool try_set_uniform (const std::string aName, const integer3_uniform_type &aValue) const
 assign a value to a integer3 uniform
 
bool try_set_uniform (const std::string aName, const integer4_uniform_type &aValue) const
 assign a value to a integer4 uniform
 
bool try_set_uniform (const std::string &aName, const std::vector< GLint > &aValue) const
 assign a value to a integer uniform array
 
bool try_set_uniform (const std::string &aName, const std::vector< integer2_uniform_type > &aValue) const
 assign a value to a integer2 uniform array
 
bool try_set_uniform (const std::string &aName, const std::vector< integer3_uniform_type > &aValue) const
 assign a value to a integer3 uniform array
 
bool try_set_uniform (const std::string &aName, const std::vector< integer4_uniform_type > &aValue) const
 assign a value to a integer4 uniform array
 
bool try_set_uniform (const std::string &aName, const graphics_matrix4x4_type &avalue) const
 assign a value to a bool uniform
 
bool try_set_uniform (const std::string &aName, const std::vector< graphics_matrix4x4_type > &avalue) const
 assign a mat4x4 uniform array from a vector of mat4x4s
 
bool try_set_uniform (const std::string &aName, const gdk::webgl1es2_texture &aTexture) const
 bind a texture to the context then assign it to a texture uniform
 
void useProgram () const
 bind an array of textures to the context then assign them to texture uniforms
 
bool operator== (const webgl1es2_shader_program &) const
 equality semantics
 
bool operator!= (const webgl1es2_shader_program &) const
 equality semantics
 
 webgl1es2_shader_program (webgl1es2_shader_program &&)=default
 move semantics
 
webgl1es2_shader_programoperator= (webgl1es2_shader_program &&)=default
 move semantics
 
 webgl1es2_shader_program (std::string aVertexSource, std::string aFragmentSource)
 constructs a shader program with glsl source file contents for a vertex shader and a fragment shader
 

Static Public Member Functions

static const size_t MAX_TEXTURE_UNITS ()
 
static const size_t MAX_FRAGMENT_SHADER_INSTRUCTIONS ()
 
static const size_t MAX_VERTEX_SHADER_INSTRUCTIONS ()
 

Static Public Attributes

static const jfc::lazy_ptr< gdk::webgl1es2_shader_programPinkShaderOfDeath
 shader useful for indicating some kind of failure. Performs MVP mul then colors all frags bright pink.
 
static const jfc::lazy_ptr< gdk::webgl1es2_shader_programAlphaCutOff
 

Detailed Description

Specifies drawing behaviours at the two programmable stages in the OpenGL ES 2.0/WebGL 1.0 pipeline (the vertex shader stage and fragment shader stage) TODO: array uniform methods currently force the use of vectors. should add support for c-style arrays and std::arrays.

Member Typedef Documentation

◆ active_attribute_collection_type

associative collection which maps an active attribute by its name to its index in the program. used in memoization strategy to reduce opengl api calls

◆ active_uniform_collection_type

associative collection which maps an active uniform by its name to its index in the program. used in memoization strategy to reduce opengl api calls

Member Function Documentation

◆ try_set_uniform()

bool gdk::webgl1es2_shader_program::try_set_uniform ( const std::string & aName,
const graphics_matrix4x4_type & avalue ) const

assign a value to a bool uniform

assign a value to a bvec2 uniform assign a value to a bvec3 uniform assign a value to a bvec4 uniform assign a value to a bool uniform array assign a value to a bvec2 uniform array assign a value to a bvec3 uniform array assign a value to a bvec4 uniform array assign a mat4x4 uniform from a mat4x4

◆ useProgram()

void gdk::webgl1es2_shader_program::useProgram ( ) const

bind an array of textures to the context then assign them to texture uniforms

Installs this program's shaders to their corresponding programmable stages will be used for subsequent draw calls until a different program is installed.

Member Data Documentation

◆ AlphaCutOff

const jfc::lazy_ptr<gdk::webgl1es2_shader_program> gdk::webgl1es2_shader_program::AlphaCutOff
static

shader for drawing unlit surfaces with alpha channel based fragment discard. Suitable for text rendering, GUI element rendering, 2D Sprite rendering. Extremely lightweight.


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