Radium Engine  1.5.20
Loading...
Searching...
No Matches
Ra::Engine::Data::ShaderProgram Class Referencefinal

#include <Engine/Data/ShaderProgram.hpp>

+ Collaboration diagram for Ra::Engine::Data::ShaderProgram:

Public Member Functions

 ShaderProgram (const Data::ShaderConfiguration &shaderConfig)
 
void load (const Data::ShaderConfiguration &shaderConfig)
 
void reload ()
 
Data::ShaderConfiguration getBasicConfiguration () const
 
void bind () const
 
void validate () const
 
void unbind () const
 
template<typename T >
void setUniform (const char *name, const T &value) const
 Uniform setters.
 
void setUniform (const char *name, Texture *tex, int texUnit) const
 
template<typename T >
void setUniform (gl::GLint location, const T &value) const
 
void setUniformTexture (const char *name, Texture *tex) const
 
globjects::Program * getProgramObject () const
 
void addShaderFromSource (Data::ShaderType type, std::unique_ptr< globjects::StaticStringSource > &&source, const std::string &name="", bool fromFile=true)
 
void link ()
 
template<>
void setUniform (const char *name, const Core::Vector2d &value) const
 
template<>
void setUniform (const char *name, const Core::Vector3d &value) const
 
template<>
void setUniform (const char *name, const Core::Vector4d &value) const
 
template<>
void setUniform (const char *name, const Core::Matrix2d &value) const
 
template<>
void setUniform (const char *name, const Core::Matrix3d &value) const
 
template<>
void setUniform (const char *name, const Core::Matrix4d &value) const
 
template<>
void setUniform (const char *name, const Scalar &value) const
 
template<>
void setUniform (const char *name, const std::vector< Scalar > &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Vector2d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Vector3d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Vector4d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Matrix2d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Matrix3d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Core::Matrix4d &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const Scalar &value) const
 
template<>
RA_ENGINE_API void setUniform (const char *name, const std::vector< Scalar > &value) const
 

Detailed Description

Abstraction of OpenGL Shader Program

See also
globjects::Program and https://www.khronos.org/opengl/wiki/Shader

Definition at line 34 of file ShaderProgram.hpp.

Constructor & Destructor Documentation

◆ ShaderProgram() [1/2]

Ra::Engine::Data::ShaderProgram::ShaderProgram ( )

Definition at line 76 of file ShaderProgram.cpp.

◆ ShaderProgram() [2/2]

Ra::Engine::Data::ShaderProgram::ShaderProgram ( const Data::ShaderConfiguration & shaderConfig)
explicit

Definition at line 83 of file ShaderProgram.cpp.

◆ ~ShaderProgram()

Ra::Engine::Data::ShaderProgram::~ShaderProgram ( )

Definition at line 87 of file ShaderProgram.cpp.

Member Function Documentation

◆ addShaderFromSource()

void Ra::Engine::Data::ShaderProgram::addShaderFromSource ( Data::ShaderType type,
std::unique_ptr< globjects::StaticStringSource > && source,
const std::string & name = "",
bool fromFile = true )
Todo
go private, and update ShaderConfiguration to add from source !

Definition at line 168 of file ShaderProgram.cpp.

◆ bind()

void Ra::Engine::Data::ShaderProgram::bind ( ) const

Definition at line 258 of file ShaderProgram.cpp.

◆ getBasicConfiguration()

ShaderConfiguration Ra::Engine::Data::ShaderProgram::getBasicConfiguration ( ) const

Definition at line 289 of file ShaderProgram.cpp.

◆ getProgramObject()

globjects::Program * Ra::Engine::Data::ShaderProgram::getProgramObject ( ) const

Definition at line 373 of file ShaderProgram.cpp.

◆ link()

void Ra::Engine::Data::ShaderProgram::link ( )
Todo
add other sampler type (or manage all type of sampler automatically)

Definition at line 210 of file ShaderProgram.cpp.

◆ load()

void Ra::Engine::Data::ShaderProgram::load ( const Data::ShaderConfiguration & shaderConfig)

Definition at line 188 of file ShaderProgram.cpp.

◆ reload()

void Ra::Engine::Data::ShaderProgram::reload ( )

Definition at line 271 of file ShaderProgram.cpp.

◆ setUniform() [1/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Matrix2d & value ) const

Definition at line 314 of file ShaderProgram.cpp.

◆ setUniform() [2/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Matrix3d & value ) const

Definition at line 319 of file ShaderProgram.cpp.

◆ setUniform() [3/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Matrix4d & value ) const

Definition at line 324 of file ShaderProgram.cpp.

◆ setUniform() [4/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Vector2d & value ) const

Definition at line 299 of file ShaderProgram.cpp.

◆ setUniform() [5/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Vector3d & value ) const

Definition at line 304 of file ShaderProgram.cpp.

◆ setUniform() [6/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Core::Vector4d & value ) const

Definition at line 309 of file ShaderProgram.cpp.

◆ setUniform() [7/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const Scalar & value ) const

Definition at line 329 of file ShaderProgram.cpp.

◆ setUniform() [8/11]

template<>
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const std::vector< Scalar > & value ) const

Definition at line 355 of file ShaderProgram.cpp.

◆ setUniform() [9/11]

template<typename T >
void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
const T & value ) const
inline

Uniform setters.

Definition at line 138 of file ShaderProgram.hpp.

◆ setUniform() [10/11]

void Ra::Engine::Data::ShaderProgram::setUniform ( const char * name,
Texture * tex,
int texUnit ) const

Definition at line 359 of file ShaderProgram.cpp.

◆ setUniform() [11/11]

template<typename T >
void Ra::Engine::Data::ShaderProgram::setUniform ( gl::GLint location,
const T & value ) const
inline

Definition at line 56 of file ShaderProgram.hpp.

◆ setUniformTexture()

void Ra::Engine::Data::ShaderProgram::setUniformTexture ( const char * name,
Texture * tex ) const

use automatic texture unit computation if you want to send a particular texture unit, use setUniform. It binds tex on an "arbitrary" tex unit.

Warning
, call a std::map::find (in O(log(active tex unit in the shader)))

Definition at line 365 of file ShaderProgram.cpp.

+ Here is the call graph for this function:

◆ unbind()

void Ra::Engine::Data::ShaderProgram::unbind ( ) const

Definition at line 267 of file ShaderProgram.cpp.

◆ validate()

void Ra::Engine::Data::ShaderProgram::validate ( ) const

Definition at line 262 of file ShaderProgram.cpp.


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