gdk-graphics  1b6d84e044c2c953fd7c9501e628a67e80f4da0d
Classes | Public Types | Public Member Functions | Static Public Attributes | List of all members
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) 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 = std::array< GLint, 2 >
 type alias used for setting int2 uniform value
 
using integer3_uniform_type = std::array< GLint, 3 >
 type alias used for setting int3 uniform value
 
using integer4_uniform_type = std::array< GLint, 4 >
 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_mat4x4_type &avalue) const
 assign a value to a bool uniform More...
 
bool try_set_uniform (const std::string &aName, const std::vector< graphics_mat4x4_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 More...
 
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 Attributes

static const jfc::shared_proxy_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::shared_proxy_ptr< gdk::webgl1es2_shader_programAlphaCutOff
 
static const size_t MAX_TEXTURE_UNITS = 8
 

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)

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_mat4x4_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::shared_proxy_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.

◆ MAX_TEXTURE_UNITS

const size_t gdk::webgl1es2_shader_program::MAX_TEXTURE_UNITS = 8
static

8 is the guaranteed minimum across all es2/web1 implementations. Can check against max but that invites the possibility of shaders working on some impls and not others.. want to avoid that, therefore define the "max" as the guaranteed minimum.


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