Shader definition class.
More...
#include <shader.hpp>
|
bool | compile (const std::string &vert, const std::string &frag) |
| Compile the vertex and fragment shaders. More...
|
|
bool | compile (GLuint &shaderId, GLenum type, const std::string &content) |
| Compile one shader using it's id, type and content. More...
|
|
bool | createProgram () |
| Create the shader program. More...
|
|
void | analyzeAttributes () |
| Analyze the shader attributes (debug mode).
|
|
void | analyzeUniforms () |
| Analyze the shader uniforms (debug mode).
|
|
std::string | getParameterType (GLenum type) |
| Get the parameter type (debug mode). More...
|
|
Shader definition class.
Manage vertex and fragment shader.
Definition at line 42 of file shader.hpp.
hx3d::graphics::Shader::Shader |
( |
std::string |
pathToShader | ) |
|
|
explicit |
Create a shader from a path. The path must be without extension, e.g. shaders/test.
This class will load the fragment and the vertex shader, using the extensions .frag.glsl
and .vert.glsl
.
- Parameters
-
pathToShader | Path to shader |
Definition at line 33 of file shader.cpp.
hx3d::graphics::Shader::Shader |
( |
std::string |
vert, |
|
|
std::string |
frag |
|
) |
| |
Create a shader from a vertex shader and a fragment shader in text form.
- Parameters
-
vert | Vertex shader code |
frag | Fragment shader code |
Definition at line 57 of file shader.cpp.
bool hx3d::graphics::Shader::compile |
( |
const std::string & |
vert, |
|
|
const std::string & |
frag |
|
) |
| |
|
protected |
Compile the vertex and fragment shaders.
- Parameters
-
vert | Vertex shader code |
frag | Fragment shader code |
- Returns
- All good / Error
Definition at line 77 of file shader.cpp.
bool hx3d::graphics::Shader::compile |
( |
GLuint & |
shaderId, |
|
|
GLenum |
type, |
|
|
const std::string & |
content |
|
) |
| |
|
protected |
Compile one shader using it's id, type and content.
- Parameters
-
- Returns
- All good / Error
Definition at line 99 of file shader.cpp.
bool hx3d::graphics::Shader::createProgram |
( |
| ) |
|
|
protected |
Create the shader program.
- Returns
- All good / Error
Definition at line 129 of file shader.cpp.
GLint hx3d::graphics::Shader::getAttribute |
( |
std::string |
name | ) |
|
Get the wanted attribute id.
- Parameters
-
- Returns
- Attribute ID
Definition at line 171 of file shader.cpp.
std::string hx3d::graphics::Shader::getParameterType |
( |
GLenum |
type | ) |
|
|
protected |
Get the parameter type (debug mode).
- Parameters
-
- Returns
- Parameter type
Definition at line 264 of file shader.cpp.
GLuint hx3d::graphics::Shader::getProgramID |
( |
| ) |
const |
Get the program ID.
- Returns
- Program ID.
Definition at line 325 of file shader.cpp.
GLint hx3d::graphics::Shader::getUniform |
( |
std::string |
name | ) |
|
Get the wanted uniform id.
- Parameters
-
- Returns
- Attribute ID
Definition at line 180 of file shader.cpp.
void hx3d::graphics::Shader::setProgramAnalyzing |
( |
bool |
value | ) |
|
|
static |
Analyse the shaders (debug mode).
- Parameters
-
Definition at line 320 of file shader.cpp.
void hx3d::graphics::Shader::setUniform1f |
( |
std::string |
uniform, |
|
|
float |
value |
|
) |
| |
Send a single float to the shader.
- Parameters
-
uniform | Uniform name |
value | Value |
Definition at line 329 of file shader.cpp.
void hx3d::graphics::Shader::setUniform2f |
( |
std::string |
uniform, |
|
|
glm::vec2 |
vector |
|
) |
| |
Send a vec2 to the shader.
- Parameters
-
uniform | Uniform name |
vector | Values |
Definition at line 334 of file shader.cpp.
void hx3d::graphics::Shader::setUniform3f |
( |
std::string |
uniform, |
|
|
glm::vec3 |
vector |
|
) |
| |
Send a vec3 to the shader.
- Parameters
-
uniform | Uniform name |
vector | Values |
Definition at line 339 of file shader.cpp.
void hx3d::graphics::Shader::setUniform4f |
( |
std::string |
uniform, |
|
|
glm::vec4 |
vector |
|
) |
| |
Send a vec4 to the shader.
- Parameters
-
uniform | Uniform name |
vector | Values |
Definition at line 344 of file shader.cpp.
void hx3d::graphics::Shader::setUniformMatrix3f |
( |
std::string |
uniform, |
|
|
glm::mat3 |
matrix |
|
) |
| |
Send a mat3 to the shader.
- Parameters
-
uniform | Uniform name |
matrix | Values |
Definition at line 349 of file shader.cpp.
void hx3d::graphics::Shader::setUniformMatrix4f |
( |
std::string |
uniform, |
|
|
glm::mat4 |
matrix |
|
) |
| |
Send a mat4 to the shader.
- Parameters
-
uniform | Uniform name |
matrix | Values |
Definition at line 354 of file shader.cpp.
void hx3d::graphics::Shader::use |
( |
Ptr< Shader > |
shader | ) |
|
|
static |
Use the shader as the current shader.
- Parameters
-
Definition at line 312 of file shader.cpp.
The documentation for this class was generated from the following files: