Kale
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Kale::OpenGL::Shader Class Reference

#include <Shader.hpp>

Public Member Functions

 Shader (const char *vertShaderFile, const char *fragShaderFile)
 
 Shader (const Shader &other)=delete
 
void operator= (const Shader &other)=delete
 
 ~Shader ()
 
void useProgram () const
 
int getAttributeLocation (const char *name) const
 
int getUniformLocation (const char *name) const
 
void uniform (unsigned int location, const Vector2f &value) const
 
void uniform (unsigned int location, const Vector3f &value) const
 
void uniform (unsigned int location, const Vector4f &value) const
 
void uniform (unsigned int location, const Matrix2f &value) const
 
void uniform (unsigned int location, const Matrix3f &value) const
 
void uniform (unsigned int location, const Matrix4f &value) const
 
void uniform (unsigned int location, const Transform &value) const
 
void uniform (unsigned int location, float value) const
 
void uniform (unsigned int location, int value) const
 
void uniform (unsigned int location, const std::vector< Vector2f > &value) const
 
void uniform (unsigned int location, const std::vector< Vector3f > &value) const
 
void uniform (unsigned int location, const std::vector< Vector4f > &value) const
 
void uniform (unsigned int location, const std::vector< Matrix2f > &value) const
 
void uniform (unsigned int location, const std::vector< Matrix3f > &value) const
 
void uniform (unsigned int location, const std::vector< Matrix4f > &value) const
 
void uniform (unsigned int location, const std::vector< Transform > &value) const
 
void uniform (unsigned int location, const std::vector< float > &value) const
 
void uniform (unsigned int location, const Vector2f *ptr, size_t size) const
 
void uniform (unsigned int location, const Vector3f *ptr, size_t size) const
 
void uniform (unsigned int location, const Vector4f *ptr, size_t size) const
 
void uniform (unsigned int location, const Matrix2f *ptr, size_t size) const
 
void uniform (unsigned int location, const Matrix3f *ptr, size_t size) const
 
void uniform (unsigned int location, const Matrix4f *ptr, size_t size) const
 
void uniform (unsigned int location, const Transform *ptr, size_t size) const
 
void uniform (unsigned int location, const float *ptr, size_t size) const
 

Private Member Functions

unsigned int createShader (unsigned int type, const char *filePath)
 

Private Attributes

unsigned int program
 

Detailed Description

Represents a single shader for use by nodes

Definition at line 28 of file Shader.hpp.

Constructor & Destructor Documentation

◆ Shader() [1/2]

Shader::Shader ( const char * vertShaderFile,
const char * fragShaderFile )

Creates, loads, and compiles a new shader program.

Parameters
vertShaderFileThe file path of the vertex shader source
fragShaderFileThe file path of the fragment shader source
Exceptions
Ifunable to compile

Creates, loads, and compiles a new shader program.

Parameters
vertShaderFileThe file path of the vertex shader source
fragShaderFileThe file path of the fragment shader source
Exceptions
ifunable to compile

Definition at line 83 of file Shader.cpp.

◆ Shader() [2/2]

Kale::OpenGL::Shader::Shader ( const Shader & other)
delete

Shaders do not support copying

◆ ~Shader()

Shader::~Shader ( )

Frees resources

Definition at line 121 of file Shader.cpp.

Member Function Documentation

◆ createShader()

unsigned int Shader::createShader ( unsigned int type,
const char * filePath )
private

Creates a shader, compiles it, and throws if unable to compile.

Parameters
typeThe type of shader
filePaththe path to the source of the shader
Returns
The shader
Exceptions
Ifunable to compile

Definition at line 39 of file Shader.cpp.

◆ getAttributeLocation()

int Shader::getAttributeLocation ( const char * name) const

Gets the location of an attribute

Parameters
nameThe name of the attribute
Returns
The location of the attribute

Definition at line 137 of file Shader.cpp.

◆ getUniformLocation()

int Shader::getUniformLocation ( const char * name) const

Gets the location of an uniform

Parameters
nameThe name of the uniform
Returns
The location of the uniform

Definition at line 146 of file Shader.cpp.

◆ operator=()

void Kale::OpenGL::Shader::operator= ( const Shader & other)
delete

Shaders do not support copying

◆ uniform() [1/25]

void Shader::uniform ( unsigned int location,
const float * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 403 of file Shader.cpp.

◆ uniform() [2/25]

void Shader::uniform ( unsigned int location,
const Matrix2f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 185 of file Shader.cpp.

◆ uniform() [3/25]

void Shader::uniform ( unsigned int location,
const Matrix2f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 359 of file Shader.cpp.

◆ uniform() [4/25]

void Shader::uniform ( unsigned int location,
const Matrix3f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 195 of file Shader.cpp.

◆ uniform() [5/25]

void Shader::uniform ( unsigned int location,
const Matrix3f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 370 of file Shader.cpp.

◆ uniform() [6/25]

void Shader::uniform ( unsigned int location,
const Matrix4f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 205 of file Shader.cpp.

◆ uniform() [7/25]

void Shader::uniform ( unsigned int location,
const Matrix4f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 381 of file Shader.cpp.

◆ uniform() [8/25]

void Shader::uniform ( unsigned int location,
const std::vector< float > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 315 of file Shader.cpp.

◆ uniform() [9/25]

void Shader::uniform ( unsigned int location,
const std::vector< Matrix2f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 275 of file Shader.cpp.

◆ uniform() [10/25]

void Shader::uniform ( unsigned int location,
const std::vector< Matrix3f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 285 of file Shader.cpp.

◆ uniform() [11/25]

void Shader::uniform ( unsigned int location,
const std::vector< Matrix4f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 295 of file Shader.cpp.

◆ uniform() [12/25]

void Shader::uniform ( unsigned int location,
const std::vector< Transform > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 305 of file Shader.cpp.

◆ uniform() [13/25]

void Shader::uniform ( unsigned int location,
const std::vector< Vector2f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 245 of file Shader.cpp.

◆ uniform() [14/25]

void Shader::uniform ( unsigned int location,
const std::vector< Vector3f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 255 of file Shader.cpp.

◆ uniform() [15/25]

void Shader::uniform ( unsigned int location,
const std::vector< Vector4f > & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 265 of file Shader.cpp.

◆ uniform() [16/25]

void Shader::uniform ( unsigned int location,
const Transform & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 215 of file Shader.cpp.

◆ uniform() [17/25]

void Shader::uniform ( unsigned int location,
const Transform * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 392 of file Shader.cpp.

◆ uniform() [18/25]

void Shader::uniform ( unsigned int location,
const Vector2f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 155 of file Shader.cpp.

◆ uniform() [19/25]

void Shader::uniform ( unsigned int location,
const Vector2f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 326 of file Shader.cpp.

◆ uniform() [20/25]

void Shader::uniform ( unsigned int location,
const Vector3f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 165 of file Shader.cpp.

◆ uniform() [21/25]

void Shader::uniform ( unsigned int location,
const Vector3f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 337 of file Shader.cpp.

◆ uniform() [22/25]

void Shader::uniform ( unsigned int location,
const Vector4f & value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 175 of file Shader.cpp.

◆ uniform() [23/25]

void Shader::uniform ( unsigned int location,
const Vector4f * ptr,
size_t size ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
ptrThe beginning pointer of the uniform values
sizeThe count of uniform values

Definition at line 348 of file Shader.cpp.

◆ uniform() [24/25]

void Shader::uniform ( unsigned int location,
float value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 225 of file Shader.cpp.

◆ uniform() [25/25]

void Shader::uniform ( unsigned int location,
int value ) const

Passes a uniform at a certain location to the shader

Parameters
locationThe location of the uniform
valueThe value of the uniform

Definition at line 235 of file Shader.cpp.

◆ useProgram()

void Shader::useProgram ( ) const

Uses this shader program for rendering

Definition at line 128 of file Shader.cpp.

Member Data Documentation

◆ program

unsigned int Kale::OpenGL::Shader::program
private

The OpenGL id of the shader program

Definition at line 34 of file Shader.hpp.


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