NDEVR
API Documentation
GLESShader

A Shader for rendering default OpenGL logic to the graphics card. More...

Classes

struct  Definition
 Defines the set of features a shader must support, used to select or compile the correct variant. More...

Public Types

enum  ShaderPart { Vertex , Fragment , Geometry }
 Identifies a stage within the shader pipeline. More...
enum  ShaderType {
  e_points , e_linework , e_solid , e_shader_type_size ,
  e_all
}
 Classifies the type of geometry a shader is designed to render. More...

Public Member Functions

 GLESShader (const Definition &def, const DynamicPointer< GLESGraphicsDevice > &device)
 Constructs a GLESShader from a definition and device.
 ~GLESShader ()
 Destroys the shader and releases GPU programs.
void bind ()
 Binds this shader program for use.
String buildFragmentSource () const
 Builds the complete fragment shader source string for the current definition.
String buildVertexSource () const
 Builds the complete vertex shader source string for the current definition.
bool checkID (int id, std::size_t value)
 Checks if a uniform value has changed since last set.
void compile (ShaderPart type, const char *src)
 Compiles a single shader stage from source.
void compileAndLink ()
 Compiles all shader stages and links the program.
const Definitiondefinition () const
 Returns the shader definition.
uint04 id () const
 Returns the unique identifier of this shader based on its definition.
void linkShader ()
 Links all compiled shader stages into a program.
template<class t_type>
void setUniformValue (const char *const location, const t_type &value)
 Sets a uniform value by name.
void unBind ()
 Unbinds this shader program.
int uniformLocation (const char *const location) const
 Returns the uniform location for a named variable.
int uniformLocation (uint08 hash, const char *const location) const
 Returns the uniform location using a pre-computed hash.
String versionedShaderCode (ShaderPart type, const String &src) const
 Prepends the appropriate GLSL version directive and defines to shader source.

Static Public Member Functions

static GLESShaderBoundShader ()
 Returns the currently bound shader.

Detailed Description

A Shader for rendering default OpenGL logic to the graphics card.


Definition at line 15 of file GLESShader.h.

Member Enumeration Documentation

◆ ShaderPart

Identifies a stage within the shader pipeline.

Enumerator
Vertex 

Vertex shader stage.

Fragment 

Fragment shader stage.

Geometry 

Geometry shader stage.

Definition at line 29 of file GLESShader.h.

◆ ShaderType

Classifies the type of geometry a shader is designed to render.

Enumerator
e_points 

Point rendering shader.

e_linework 

Line rendering shader.

e_solid 

Solid/filled rendering shader.

e_shader_type_size 

Sentinel for the number of shader types.

e_all 

Matches all shader types.

Definition at line 19 of file GLESShader.h.

Constructor & Destructor Documentation

◆ GLESShader()

GLESShader::GLESShader ( const Definition & def,
const DynamicPointer< GLESGraphicsDevice > & device )

Constructs a GLESShader from a definition and device.

Parameters
[in]defThe shader feature definition.
[in]deviceThe OpenGL graphics device.

Referenced by BoundShader().

Member Function Documentation

◆ BoundShader()

GLESShader * GLESShader::BoundShader ( )
static

Returns the currently bound shader.

Returns
A pointer to the bound GLESShader, or nullptr.

References GLESShader().

◆ buildFragmentSource()

String GLESShader::buildFragmentSource ( ) const

Builds the complete fragment shader source string for the current definition.

Returns
The GLSL fragment shader source.

◆ buildVertexSource()

String GLESShader::buildVertexSource ( ) const

Builds the complete vertex shader source string for the current definition.

Returns
The GLSL vertex shader source.

◆ checkID()

bool GLESShader::checkID ( int id,
std::size_t value )

Checks if a uniform value has changed since last set.

Parameters
[in]idThe uniform location.
[in]valueThe hash of the new value.
Returns
True if the value has changed.

◆ compile()

void GLESShader::compile ( ShaderPart type,
const char * src )

Compiles a single shader stage from source.

Parameters
[in]typeThe shader stage.
[in]srcThe GLSL source code.

◆ definition()

const Definition & GLESShader::definition ( ) const
inline

Returns the shader definition.

Returns
A const reference to the Definition.

Definition at line 248 of file GLESShader.h.

◆ id()

uint04 GLESShader::id ( ) const

Returns the unique identifier of this shader based on its definition.

Returns
The shader ID.

◆ setUniformValue()

template<class t_type>
void GLESShader::setUniformValue ( const char *const location,
const t_type & value )
inline

Sets a uniform value by name.

Parameters
[in]locationThe uniform variable name.
[in]valueThe value to set.

Definition at line 185 of file GLESShader.h.

References setUniformValue(), and uniformLocation().

Referenced by setUniformValue().

◆ uniformLocation() [1/2]

int GLESShader::uniformLocation ( const char *const location) const
inline

Returns the uniform location for a named variable.

Parameters
[in]locationThe uniform variable name.
Returns
The uniform location index, or -1 if not found.

Definition at line 106 of file GLESShader.h.

References String::hash(), and uniformLocation().

Referenced by setUniformValue(), and uniformLocation().

◆ uniformLocation() [2/2]

int GLESShader::uniformLocation ( uint08 hash,
const char *const location ) const

Returns the uniform location using a pre-computed hash.

Parameters
[in]hashThe hash of the variable name.
[in]locationThe uniform variable name.
Returns
The uniform location index, or -1 if not found.

◆ versionedShaderCode()

String GLESShader::versionedShaderCode ( ShaderPart type,
const String & src ) const

Prepends the appropriate GLSL version directive and defines to shader source.

Parameters
[in]typeThe shader stage.
[in]srcThe original GLSL source.
Returns
The versioned shader source string.

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