Allolib  1.0
C++ Components For Interactive Multimedia
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
al::ShaderProgram Class Reference

Shader program object. More...

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/graphics/al_Shader.hpp>

Inheritance diagram for al::ShaderProgram:
al::ShaderBase al::GPUObject

Classes

struct  Attribute
 

Public Types

enum  Type {
  NONE = 0 , FLOAT , VEC2 , VEC3 ,
  VEC4 , INT , INT2 , INT3 ,
  INT4 , BOOL , BOOL2 , BOOL3 ,
  BOOL4 , MAT22 , MAT33 , MAT44 ,
  SAMPLER_1D , SAMPLER_2D , SAMPLER_RECT , SAMPLER_3D ,
  SAMPLER_CUBE , SAMPLER_1D_SHADOW , SAMPLER_2D_SHADOW
}
 

Public Member Functions

virtual ~ShaderProgram ()
 Any attached shaders will automatically be detached, but not deleted.
 
ShaderProgramattach (Shader &s)
 Attach shader to program. More...
 
const ShaderProgramdetach (const Shader &s) const
 Detach shader from program.
 
const ShaderProgramlink (bool doValidate=true) const
 Link attached shaders. More...
 
bool compile (const std::string &vertSource, const std::string &fragSource, const std::string &geomSource="")
 Compile and link shader sources.
 
const ShaderProgramuse ()
 
void begin ()
 Begin use of shader program.
 
void end () const
 End use of shader program.
 
bool linked () const
 Returns whether program linked successfully.
 
bool validateProgram (bool printLog=false) const
 Returns whether linked program can execute in current graphics state.
 
void listParams () const
 Print out all the input parameters to the shader.
 
int getUniformLocation (const char *name) const
 Get location of uniform.
 
int getUniformLocation (const std::string &s) const
 
int attribute (const char *name) const
 Get location of attribute.
 
const ShaderProgramuniform (const char *name, const Color &c) const
 
void uniform4f (int loc, float v0, float v1, float v2, float v3) const
 
void uniformMat4f (int loc, float *data) const
 
const ShaderProgramuniform (int loc, int v) const
 
const ShaderProgramuniform (int loc, float v) const
 
const ShaderProgramuniform (int loc, double v) const
 
const ShaderProgramuniform (int loc, float v0, float v1) const
 
const ShaderProgramuniform (int loc, float v0, float v1, float v2) const
 
const ShaderProgramuniform (int loc, float v0, float v1, float v2, float v3) const
 
const ShaderProgramuniform4v (int loc, const float *v, int count=1) const
 
template<typename T >
const ShaderProgramuniform (int loc, const Vec< 2, T > &v) const
 
template<typename T >
const ShaderProgramuniform (int loc, const Vec< 3, T > &v) const
 
template<typename T >
const ShaderProgramuniform (int loc, const Vec< 4, T > &v) const
 
const ShaderProgramuniformMatrix3 (int loc, const float *v, bool transpose=false) const
 
const ShaderProgramuniformMatrix4 (int loc, const float *v, bool transpose=false) const
 
const ShaderProgramuniform (int loc, const Mat< 4, float > &m) const
 
template<typename T >
const ShaderProgramuniform (int loc, const Mat< 4, T > &m) const
 
const ShaderProgramuniform (const char *name, int v) const
 
const ShaderProgramuniform (const char *name, float v) const
 
const ShaderProgramuniform (const char *name, double v) const
 
const ShaderProgramuniform (const char *name, float v0, float v1) const
 
const ShaderProgramuniform (const char *name, float v0, float v1, float v2) const
 
const ShaderProgramuniform (const char *name, float v0, float v1, float v2, float v3) const
 
template<typename T >
const ShaderProgramuniform (const char *name, const Vec< 2, T > &v) const
 
template<typename T >
const ShaderProgramuniform (const char *name, const Vec< 3, T > &v) const
 
template<typename T >
const ShaderProgramuniform (const char *name, const Vec< 4, T > &v) const
 
const ShaderProgramuniform (const char *name, const Mat< 4, float > &m, bool transpose=false) const
 
template<typename T >
const ShaderProgramuniform (const char *name, const Mat< 4, T > &m, bool transpose=false) const
 
template<typename T >
const ShaderProgramuniform (const char *name, const Quat< T > &q) const
 
const ShaderProgramuniform1 (const char *name, const float *v, int count=1) const
 
const ShaderProgramuniform2 (const char *name, const float *v, int count=1) const
 
const ShaderProgramuniform3 (const char *name, const float *v, int count=1) const
 
const ShaderProgramuniform4 (const char *name, const float *v, int count=1) const
 
const ShaderProgramuniformMatrix3 (const char *name, const float *v, bool transpose=false) const
 
const ShaderProgramuniformMatrix4 (const char *name, const float *v, bool transpose=false) const
 
const ShaderProgramattribute (int loc, float v) const
 
const ShaderProgramattribute (int loc, float v0, float v1) const
 
const ShaderProgramattribute (int loc, float v0, float v1, float v2) const
 
const ShaderProgramattribute (int loc, float v0, float v1, float v2, float v3) const
 
const ShaderProgramattribute (const char *name, float v) const
 
const ShaderProgramattribute (const char *name, float v0, float v1) const
 
const ShaderProgramattribute (const char *name, float v0, float v1, float v2) const
 
const ShaderProgramattribute (const char *name, float v0, float v1, float v2, float v3) const
 
const ShaderProgramattribute1 (const char *name, const float *v) const
 
const ShaderProgramattribute2 (const char *name, const float *v) const
 
const ShaderProgramattribute3 (const char *name, const float *v) const
 
const ShaderProgramattribute4 (const char *name, const float *v) const
 
const ShaderProgramattribute1 (int loc, const double *v) const
 
const ShaderProgramattribute2 (int loc, const double *v) const
 
const ShaderProgramattribute3 (int loc, const double *v) const
 
const ShaderProgramattribute4 (int loc, const double *v) const
 
template<typename T >
const ShaderProgramattribute (int loc, const Vec< 2, T > &v) const
 
template<typename T >
const ShaderProgramattribute (int loc, const Vec< 3, T > &v) const
 
template<typename T >
const ShaderProgramattribute (int loc, const Vec< 4, T > &v) const
 
template<typename T >
const ShaderProgramattribute (int loc, const Quat< T > &q) const
 
const char * log () const
 Returns info log or 0 if none.
 
void printLog () const
 Prints info log, if any.
 
bool created () const
 Returns whether object has been created.
 
void create ()
 Creates object on GPU.
 
void destroy ()
 Destroys object on GPU.
 
unsigned long id () const
 Returns the assigned object id.
 
void id (unsigned long v)
 
void validate ()
 Ensure that the GPUObject is ready to use. More...
 
void invalidate ()
 Triggers re-creation of object safely.
 

Static Public Member Functions

static void use (unsigned programID)
 

Protected Member Functions

virtual void get (int pname, void *params) const
 
virtual void getLog (char *buf) const
 
virtual void onCreate ()
 Called when currently assigned context is created.
 
virtual void onDestroy ()
 Called when currently assigned context is destroyed.
 

Protected Attributes

std::string mVertSource
 
std::string mFragSource
 
std::string mGeomSource
 
std::unordered_map< std::string, int > mUniformLocs
 
std::unordered_map< std::string, int > mAttribLocs
 
unsigned int mID
 
bool mResubmit
 

Detailed Description

Shader program object.

A program object represents a useable part of render pipeline. It links one or more shader units into a single program object.

Definition at line 116 of file al_Shader.hpp.

Member Enumeration Documentation

◆ Type

The basic parameter types

Enumerator
FLOAT 

A single float value.

VEC2 

Two float values.

VEC3 

Three float values.

VEC4 

Four float values.

INT 

A single int value.

INT2 

Two int values.

INT3 

Three int values.

INT4 

Four int values.

BOOL 

A single bool value.

BOOL2 

Two bool values.

BOOL3 

Three bool values.

BOOL4 

Four bool values.

MAT22 

A 2x2 matrix.

MAT33 

A 3x3 matrix.

MAT44 

A 4x4 matrix.

SAMPLER_1D 

A 1D texture.

SAMPLER_2D 

A 2D texture.

SAMPLER_RECT 

A rectangular texture.

SAMPLER_3D 

A 3D texture.

SAMPLER_CUBE 

A cubemap texture.

SAMPLER_1D_SHADOW 

A 1D depth texture.

SAMPLER_2D_SHADOW 

A 2D depth texture.

Definition at line 121 of file al_Shader.hpp.

Member Function Documentation

◆ attach()

ShaderProgram& al::ShaderProgram::attach ( Shader s)

Attach shader to program.

The input shader will be compiled if necessary.

◆ link()

const ShaderProgram& al::ShaderProgram::link ( bool  doValidate = true) const

Link attached shaders.

Parameters
[in]doValidatevalidate program after linking; You might not want to do this if you need to set uniforms before validating, e.g., when using different texture sampler types in the same shader.

◆ validate()

void al::GPUObject::validate ( )
inherited

Ensure that the GPUObject is ready to use.

This is typically placed before any rendering implementation. If the object has been invalidated, the object will be destroyed and then created again. Otherwise, the object will simply be created if not already created.


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