Radium Engine
1.5.20
|
#include <Engine/Data/ShaderConfiguration.hpp>
Static Public Member Functions | |
static ShaderConfiguration | getDefaultShaderConfig () |
static void | setOpenGLVersion (const glbinding::Version &version) |
set the OpenGL version to use in the generated header for shaders. | |
static std::string | getGLSLVersion () |
get the OpenGL version used in the generated header for shaders. | |
Friends | |
class | ShaderProgram |
std::ostream & | operator<< (std::ostream &stream, const ShaderConfiguration &config) |
A class used to create shader programs later on. A ShaderConfiguration should be added once to the ShaderConfigurationFactory, then the factory must be used to retrieve the added shader configurations. Typical use case : **************************** CREATION **************************** // Create the shader configuration once (see MainApplication::addBasicShaders for example) ShaderConfiguration config("MyConfig"); // Add shader files to the config (note that the file extensions can be whatever you want) config.addShader(ShaderType_VERTEX, "path/to/shader.vert.glsl"); config.addShader(ShaderType_FRAGMENT, "path/to/shader.frag.glsl"); // Same for other shader types. Vertex and fragment are required, other are optional // Note that, for a compute shader, only the compute shader is needed. // Add eventually some properties to the shader configuration config.addProperties( {"USE_MICROFACET;", "MICROFACET_DISTRIBUTION Trowbridge_Reitz;"} ); // Add also some includes if needed config.addInclude{"\"MicrofacetFunctions.glsl\";"); // Add the configuration to the factory ShaderConfigurationFactory::addConfiguration(config);
**************************** USAGE **************************** // When you want to reuse created shader configurations, just set it using auto config = ShaderConfigurationFactory::getConfiguration("MyConfig"); // You can then use it to extract the shader from the ShaderProgramManager and use it auto shader = ShaderProgramManager::getInstance()->getShaderProgram(); shader->bind(); ...
Definition at line 61 of file ShaderConfiguration.hpp.
|
explicit |
Initializes a shader configuration with a name Warning: This does not query the corresponding configuration in the ShaderConfigurationFactory. The proper way to do this is by calling ShaderConfigurationFactory::getConfiguration(name);
Definition at line 47 of file ShaderConfiguration.cpp.
Ra::Engine::Data::ShaderConfiguration::ShaderConfiguration | ( | const std::string & | name, |
const std::string & | vertexShader, | ||
const std::string & | fragmentShader ) |
Initializes a configuration with a name, a vertex and a fragment shader This does not add the configuration to the factory ShaderConfigurationFactory::addConfiguration(config) must be called.
Definition at line 50 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addInclude | ( | const std::string & | incl, |
ShaderType | type = ShaderType_FRAGMENT ) |
Add a property in the form of an #include The same shader files with different properties leads to different shader programs
Definition at line 80 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addIncludes | ( | const std::list< std::string > & | incls, |
ShaderType | type = ShaderType_FRAGMENT ) |
Definition at line 84 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addNamedString | ( | const std::string & | includepath, |
const std::string & | realfile ) |
Manage named strings (see ShaderProgramManager::addNamedString)
Definition at line 95 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addProperties | ( | const std::list< std::string > & | props | ) |
Definition at line 70 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addProperty | ( | const std::string & | prop | ) |
Add a property in the form of a #define The same shader files with different properties leads to different shader programs
Definition at line 66 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addShader | ( | ShaderType | type, |
const std::string & | name ) |
Add a shader, from a file, given its type
type | the Type of the shader |
name | the file to load |
Definition at line 58 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::addShaderSource | ( | ShaderType | type, |
const std::string & | source ) |
Add a shader, given its glsl source code, of a given type. When a shader is added from a glsl source string, when reloading programs, only the parts coming from files are reloaded.
type | |
source | the source code of the shader |
Definition at line 62 of file ShaderConfiguration.cpp.
|
inlinestatic |
Definition at line 129 of file ShaderConfiguration.hpp.
|
static |
get the OpenGL version used in the generated header for shaders.
Definition at line 178 of file ShaderConfiguration.cpp.
const std::vector< std::pair< std::string, ShaderType > > & Ra::Engine::Data::ShaderConfiguration::getIncludes | ( | ) | const |
Definition at line 149 of file ShaderConfiguration.cpp.
|
inline |
Definition at line 134 of file ShaderConfiguration.hpp.
const std::vector< std::pair< std::string, std::string > > & Ra::Engine::Data::ShaderConfiguration::getNamedStrings | ( | ) | const |
Definition at line 154 of file ShaderConfiguration.cpp.
std::set< std::string > Ra::Engine::Data::ShaderConfiguration::getProperties | ( | ) | const |
Definition at line 145 of file ShaderConfiguration.cpp.
|
inline |
Definition at line 135 of file ShaderConfiguration.hpp.
bool Ra::Engine::Data::ShaderConfiguration::isComplete | ( | ) | const |
Tell if a shader configuration has at least a vertex and a fragment shader, or a compute shader.
Definition at line 100 of file ShaderConfiguration.cpp.
bool Ra::Engine::Data::ShaderConfiguration::operator< | ( | const ShaderConfiguration & | other | ) | const |
Definition at line 106 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::removeInclude | ( | const std::string & | incl, |
ShaderType | type = ShaderType_FRAGMENT ) |
Definition at line 90 of file ShaderConfiguration.cpp.
void Ra::Engine::Data::ShaderConfiguration::removeProperty | ( | const std::string & | prop | ) |
Definition at line 76 of file ShaderConfiguration.cpp.
|
inline |
Definition at line 132 of file ShaderConfiguration.hpp.
|
static |
set the OpenGL version to use in the generated header for shaders.
glbinding::Version | (e.g. {4,1}) |
Definition at line 160 of file ShaderConfiguration.cpp.
|
inline |
Definition at line 131 of file ShaderConfiguration.hpp.
|
friend |
Definition at line 22 of file ShaderConfiguration.cpp.
|
friend |
Definition at line 63 of file ShaderConfiguration.hpp.