3#ifndef GDK_GFX_WEBGL1ES2_SHADER_PROGRAM_H
4#define GDK_GFX_WEBGL1ES2_SHADER_PROGRAM_H
6#include <gdk/graphics_types.h>
8#include <gdk/shader_program.h>
9#include <gdk/webgl1es2_texture.h>
10#include <jfc/unique_handle.h>
11#include <jfc/lazy_ptr.h>
17#include <unordered_map>
56 const std::string &aAttributeName)
const;
61 bool try_set_uniform(
const std::string &aName,
const graphics_vector2_type &aValue)
const;
63 bool try_set_uniform(
const std::string &aName,
const graphics_vector3_type &aValue)
const;
65 bool try_set_uniform(
const std::string &aName,
const graphics_vector4_type &aValue)
const;
67 bool try_set_uniform(
const std::string &aName,
const std::vector<GLfloat> &avalue)
const;
69 bool try_set_uniform(
const std::string &aName,
const std::vector<graphics_vector2_type> &avalue)
const;
71 bool try_set_uniform(
const std::string &aName,
const std::vector<graphics_vector3_type> &avalue)
const;
73 bool try_set_uniform(
const std::string &aName,
const std::vector<graphics_vector4_type> &avalue)
const;
85 bool try_set_uniform(
const std::string &aName,
const std::vector<GLint> &aValue)
const;
87 bool try_set_uniform(
const std::string &aName,
const std::vector<integer2_uniform_type> &aValue)
const;
89 bool try_set_uniform(
const std::string &aName,
const std::vector<integer3_uniform_type> &aValue)
const;
91 bool try_set_uniform(
const std::string &aName,
const std::vector<integer4_uniform_type> &aValue)
const;
114 bool try_set_uniform(const std::string &aName, const std::vector<graphics_mat2x2_type> &avalue) const;
117 bool try_set_uniform(const std::string &aName, const graphics_mat3x3_type &avalue) const;
119 bool try_set_uniform(const std::string &aName, const std::vector<graphics_mat3x3_type> &avalue) const;*/
122 bool try_set_uniform(
const std::string &aName,
const graphics_matrix4x4_type &avalue)
const;
124 bool try_set_uniform(
const std::string &aName,
const std::vector<graphics_matrix4x4_type> &avalue)
const;
156 static const jfc::lazy_ptr<gdk::webgl1es2_shader_program>
AlphaCutOff;
158 static const size_t MAX_TEXTURE_UNITS();
159 static const size_t MAX_FRAGMENT_SHADER_INSTRUCTIONS();
160 static const size_t MAX_VERTEX_SHADER_INSTRUCTIONS();
164 jfc::unique_handle<GLuint> m_VertexShaderHandle;
167 jfc::unique_handle<GLuint> m_FragmentShaderHandle;
170 jfc::unique_handle<GLuint> m_ProgramHandle;
std::unordered_map< std::string, active_uniform_info > active_uniform_collection_type
Definition webgl1es2_shader_program.h:44
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 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 GLfloat aValue) const
assign a float1 uniform from a float
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
webgl1es2_shader_program & operator=(webgl1es2_shader_program &&)=default
move semantics
std::optional< active_attribute_info > tryGetActiveAttribute(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 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< GLint > &aValue) const
assign a value to a integer uniform array
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 integer2_uniform_type &aValue) const
assign a value to a integer2 uniform
static const jfc::lazy_ptr< gdk::webgl1es2_shader_program > PinkShaderOfDeath
shader useful for indicating some kind of failure. Performs MVP mul then colors all frags bright pink...
Definition webgl1es2_shader_program.h:152
bool try_set_uniform(const std::string &aName, const std::vector< GLfloat > &avalue) const
assign a float uniform array from an array of floats
graphics_intvector2_type integer2_uniform_type
type alias used for setting int2 uniform value
Definition webgl1es2_shader_program.h:47
graphics_intvector4_type integer4_uniform_type
type alias used for setting int4 uniform value
Definition webgl1es2_shader_program.h:51
bool operator!=(const webgl1es2_shader_program &) const
equality semantics
std::unordered_map< std::string, active_attribute_info > active_attribute_collection_type
Definition webgl1es2_shader_program.h:41
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 integer4_uniform_type &aValue) const
assign a value to a integer4 uniform
bool operator==(const webgl1es2_shader_program &) const
equality semantics
void useProgram() const
bind an array of textures to the context then assign them to texture uniforms
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
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 std::vector< graphics_vector3_type > &avalue) const
assign a value to a float3 uniform array from a vector of float3s
static const jfc::lazy_ptr< gdk::webgl1es2_shader_program > AlphaCutOff
Definition webgl1es2_shader_program.h:156
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
bool try_set_uniform(const std::string &aName, const GLint aValue) const
assign a value to a integer uniform
webgl1es2_shader_program(webgl1es2_shader_program &&)=default
move semantics
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
graphics_intvector3_type integer3_uniform_type
type alias used for setting int3 uniform value
Definition webgl1es2_shader_program.h:49
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
Definition webgl1es2_texture.h:19
index, size, type of an active attribute used in the shader program
Definition webgl1es2_shader_program.h:26
GLenum type
type of the attribute's components, e.g: float
Definition webgl1es2_shader_program.h:28
GLint count
number of attributes
Definition webgl1es2_shader_program.h:29
GLint location
location of the attribute
Definition webgl1es2_shader_program.h:27