jGL
|
Generic shader program with vertex and fragment shader. More...
#include <shader.h>
Public Member Functions | |
Shader (const char *v, const char *f) | |
Construct a Shader from a vertex and fragment source. | |
Shader () | |
Construct an empty Shader. | |
Shader (std::string path, std::string name) | |
Construct a Shader from source given by paths. | |
virtual | ~Shader ()=default |
bool | operator== (const Shader &s) |
bool | lint () |
Check for common shader errors. | |
template<class T > | |
void | setUniform (std::string name, T value) |
Set a Uniform to a value. | |
const std::string & | getVertex () const |
const std::string & | getFragment () const |
template<class T > | |
jGLUniform< T > | getUniform (std::string name) |
Get a Uniform by name. | |
std::vector< std::string > | getUniformNames () |
Get all the parsed uniforms in the Shader. | |
virtual void | use ()=0 |
Use the shader. | |
std::string | displayVertexSource () const |
Display the vertex shader with line numbers. | |
std::string | displayFragmentSource () const |
Display the fragment shader with line numbers. | |
Protected Member Functions | |
std::string | parseShaderSource (std::ifstream &file) |
virtual void | compile ()=0 |
bool | parseUniforms () |
std::string | formatWithLineNumbers (std::string shader) const |
template<class T > | |
void | detectUniformsAndCreate (std::string code) |
virtual void | setValue (jGLUniform< int > *u, int value) |
virtual void | setValue (jGLUniform< Sampler2D > *u, Sampler2D value) |
virtual void | setValue (jGLUniform< float > *u, float value) |
virtual void | setValue (jGLUniform< glm::vec2 > *u, glm::vec2 value) |
virtual void | setValue (jGLUniform< glm::vec4 > *u, glm::vec4 value) |
virtual void | setValue (jGLUniform< glm::mat4 > *u, glm::mat4 value) |
Protected Attributes | |
std::string | vertex |
std::string | fragment |
std::unordered_map< std::string, std::shared_ptr< AbstractjGLUniform > > | uniforms |
Generic shader program with vertex and fragment shader.
|
inline |
Construct a Shader from a vertex and fragment source.
v | vertex shader source. |
f | fragment shader source. |
|
inline |
Construct an empty Shader.
jGL::Shader::Shader | ( | std::string | path, |
std::string | name | ||
) |
Construct a Shader from source given by paths.
path | path the .vs and .fs shader sources. |
name | name of sources in path: name.vs and name.fs |
|
virtualdefault |
|
protectedpure virtual |
Implemented in jGL::GL::glShader.
|
inlineprotected |
|
inline |
Display the fragment shader with line numbers.
|
inline |
Display the vertex shader with line numbers.
|
inlineprotected |
|
inline |
|
inline |
Get a Uniform by name.
T | the type of the uniform. |
name | the name of the uniform to get. |
|
inline |
Get all the parsed uniforms in the Shader.
|
inline |
bool jGL::Shader::lint | ( | ) |
Check for common shader errors.
|
inline |
|
protected |
|
protected |
|
inline |
Set a Uniform to a value.
T | the type of uniform. |
name | the name of the uniform. |
value | the value of type T. |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
pure virtual |
Use the shader.
Implemented in jGL::GL::glShader, and jGL::Vulkan::vkShader.
|
protected |
|
protected |
|
protected |