Number5
Visualisierung 2 Project - Florian Schober (0828151, f.schober@live.com), Andreas Walch (0926780, walch.andreas89@gmail.com)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Shader Class Reference

#include <Shader.hpp>

Public Member Functions

 Shader (string const &name)
 
 ~Shader ()
 
void use ()
 
GLint uniform (string const &name)
 
GLint uniformBlock (string const &name)
 
void uniform (string const &name, mat4 const *values, size_t const size)
 
void uniform (string const &name, mat4 const &value)
 
void uniform (string const &name, mat3 const &value)
 
void uniform (string const &name, vec4 const &value)
 
void uniform (string const &name, vec3 const &value)
 
void uniform (string const &name, vec2 const &value)
 
void uniform (string const &name, float value)
 
void uniform (string const &name, int value)
 
void uniform (string const &name, uint value)
 
void uniform (string const &name, uint16 value)
 

Static Public Attributes

static const uint position = 0
 
static const uint normal = 1
 
static const uint uv = 2
 
static const uint boneId = 3
 
static const uint boneWeight = 4
 

Private Member Functions

int loadShader (string const &file, GLenum shaderType)
 
void link ()
 

Private Attributes

uint m_id
 
string m_name
 
map< string, GLint > m_uniforms
 

Detailed Description

Shader represents a shader-program of OpenGL

Definition at line 8 of file Shader.hpp.

Constructor & Destructor Documentation

Shader ( string const &  name)

Constructs a Shader-object. Vertex- and fragment-shader are loaded from files (i.e. "content\\shaders\\" + name + ".vert").

Parameters
nameThe name of the shader

Definition at line 4 of file Shader.cpp.

~Shader ( )

Destructs a Shader-object

Definition at line 28 of file Shader.cpp.

Member Function Documentation

void link ( )
private

Links all loaded shaders to a shader-program

Definition at line 88 of file Shader.cpp.

int loadShader ( string const &  file,
GLenum  shaderType 
)
private

Loads a shader from a file and compiles it.

Parameters
fileThe filename
shaderTypethe type of the shader
Returns
The shader-id

Definition at line 34 of file Shader.cpp.

GLint uniform ( string const &  name)

Returns the position for the given uniform.

Parameters
nameThe uniform-name
Returns
The position

Definition at line 115 of file Shader.cpp.

void uniform ( string const &  name,
mat4 const *  values,
size_t const  size 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valuesA pointer to an array to mat4
sizeThe number of elements read from the array

Definition at line 50 of file Shader.hpp.

void uniform ( string const &  name,
mat4 const &  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 57 of file Shader.hpp.

void uniform ( string const &  name,
mat3 const &  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 63 of file Shader.hpp.

void uniform ( string const &  name,
vec4 const &  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 69 of file Shader.hpp.

void uniform ( string const &  name,
vec3 const &  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 75 of file Shader.hpp.

void uniform ( string const &  name,
vec2 const &  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 81 of file Shader.hpp.

void uniform ( string const &  name,
float  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 87 of file Shader.hpp.

void uniform ( string const &  name,
int  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 93 of file Shader.hpp.

void uniform ( string const &  name,
uint  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 99 of file Shader.hpp.

void uniform ( string const &  name,
uint16  value 
)
inline

Set a uniform to the given value

Parameters
nameThe uniform-name
valueThe new value for the uniform

Definition at line 105 of file Shader.hpp.

GLint uniformBlock ( string const &  name)

Returns the position for the given uniform-block.

Parameters
nameThe uniform-block-name
Returns
The position

Definition at line 125 of file Shader.cpp.

void use ( )

Activates this shader-object

Definition at line 111 of file Shader.cpp.

Member Data Documentation

const uint boneId = 3
static

The layout-location for boneId-attributes

Definition at line 125 of file Shader.hpp.

const uint boneWeight = 4
static

The layout-location for boneWeight-attributes

Definition at line 126 of file Shader.hpp.

uint m_id
private

The OpenGL id

Definition at line 10 of file Shader.hpp.

string m_name
private

The shader-name

Definition at line 11 of file Shader.hpp.

map<string,GLint> m_uniforms
private

Uniform-positions by their name

Definition at line 12 of file Shader.hpp.

const uint normal = 1
static

The layout-location for normal-attributes

Definition at line 123 of file Shader.hpp.

const uint position = 0
static

The layout-location for position-attributes

Definition at line 122 of file Shader.hpp.

const uint uv = 2
static

The layout-location for uv-attributes

Definition at line 124 of file Shader.hpp.


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