![]() |
xyginext
0.2.0
Second generation of xygine game creation framework
|
Specialised resource manager for shaders. More...
#include <ShaderResource.hpp>
Public Types | |
using | ID = sf::Int32 |
Public Member Functions | |
ShaderResource (const ShaderResource &)=delete | |
ShaderResource (ShaderResource &&)=delete | |
ShaderResource & | operator= (const ShaderResource &)=delete |
ShaderResource & | operator= (ShaderResource &&)=delete |
sf::Shader & | get (ID) |
get a reference to the shader corresponding to the given ID More... | |
void | preload (ID, const std::string &, const std::string &) |
Preloads a shader. More... | |
void | preload (ID, const std::string &, sf::Shader::Type) |
Preloads a shader. More... | |
bool | exists (ID id) |
Returns true if the given ID is already in use. | |
Specialised resource manager for shaders.
sf::Shader& xy::ShaderResource::get | ( | ID | ) |
get a reference to the shader corresponding to the given ID
Before a shader can be returned it must be preloaded and associated with the given ID. If using custom shaders along side the built in xygine shaders the the Unique ID should start at least Shader::Type::Count
void xy::ShaderResource::preload | ( | ID | , |
const std::string & | , | ||
const std::string & | |||
) |
Preloads a shader.
Shaders need to be loaded and compiled before they can be used which can be a time consuming action. Preloading shaders when other resources are loaded allows shaders to be returned more efficiently at run time.
ID | A unique 32 bit integer to identify the loaded shader |
string | A string containing the source for the vertex shader. The string can either be a constant stored within a source file, or loaded from an external file at run time. |
string | A string containing the source for the fragment shader. The string can either be a constant stored within a source file, or loaded from an external file at run time. |
void xy::ShaderResource::preload | ( | ID | , |
const std::string & | , | ||
sf::Shader::Type | |||
) |
Preloads a shader.
Shaders need to be loaded and compiled before they can be used which can be a time consuming action. Preloading shaders when other resources are loaded allows shaders to be returned more efficiently at run time.
ID | A unique 32 bit integer to identify the loaded shader |
string | A string containing the source for a vertex or fragment shader. The string can either be a constant stored within a source file, or loaded from an external file at run time. |
sf::Shader::Type | Shader type describing whether the source is a vertex or fragment shader. |