Represents a shader consisting of a vertex and pixel shader.
Represents a shader consisting of a vertex and pixel shader. Also stores ids of standard uniforms. Use the Renderer class below to create these.
|
| Shader (const char *filename, const std::vector< std::string > &local_defines, Renderer *renderer) |
|
| Shader (ShaderHandle program, ShaderHandle vs, ShaderHandle ps) |
|
void | UpdateGlobalDefines (const std::vector< std::string > &global_defines_to_add, const std::vector< std::string > &global_defines_to_omit) |
| Recalculates the defines of this shader, and marks dirty if they differ from the last Reload(). More...
|
|
bool | ReloadIfDirty () |
| If the shader has been marked dirty, reload it and clear the dirty flag. More...
|
|
virtual void | Load () |
| Loads and unpacks the Shader from filename_ into data_ .
|
|
virtual bool | Finalize () |
| Creates a Shader from data_ .
|
|
bool | IsValid () |
| Whether this object loaded and finalized correctly. Call after Finalize has been called (by AssetManager::TryFinalize).
|
|
void | Set (const Renderer &renderer) const |
| Activate this shader for subsequent draw calls. More...
|
|
UniformHandle | FindUniform (const char *uniform_name) |
| Find a non-standard uniform by name. More...
|
|
void | SetUniform (UniformHandle uniform_loc, const float *value, size_t num_components) |
| Raw call to set any uniform (with 1/2/3/4/16 components). More...
|
|
template<int N> |
void | SetUniform (UniformHandle uniform_loc, const mathfu::Vector< float, N > &value) |
| Set an non-standard uniform to a vec2/3/4 value. More...
|
|
template<int N> |
bool | SetUniform (const char *uniform_name, const mathfu::Vector< float, N > &value) |
| Convenience call that does a Lookup and a Set if found. More...
|
|
bool | SetUniform (const char *uniform_name, float value) |
| Set a non-standard uniform to a float value. More...
|
|
bool | SetUniform (const char *uniform_name, const mathfu::mat4 &value) |
| Set a non-standard uniform to a mat4 value. More...
|
|
void | InitializeUniforms () |
|
ShaderHandle | program () const |
|
bool | HasDefine (const char *define) const |
|
bool | IsDirty () const |
|
void | MarkDirty () |
| Call to mark the shader as needing to be reloaded. More...
|
|
ShaderImpl * | impl () |
|
| AsyncAsset () |
| Default constructor for an empty AsyncAsset.
|
|
| AsyncAsset (const char *filename) |
| Construct an AsyncAsset with a given file name. More...
|
|
virtual | ~AsyncAsset () |
| AsyncAsset destructor.
|
|
bool | LoadNow () |
| Performs a synchronous load by calling Load & Finalize. More...
|
|
void | set_filename (const std::string &filename) |
| Sets the filename that should be loaded. More...
|
|
const std::string & | filename () const |
| The name of the file associated with the resource. More...
|
|
void | AddFinalizeCallback (AssetFinalizedCallback callback) |
| Adds a callback to be called when the asset is finalized. More...
|
|
void | IncreaseRefCount () |
| indicate there is an additional owner of this asset. By default, when you call any of the UnLoad*() functions in the AssetManager, that will directly delete the asset since they all start out with a single reference count. Call this function to indicate multiple owners will call Unload*() independently, and only have the asset deleted by the last one.
|
|
void fplbase::Shader::UpdateGlobalDefines |
( |
const std::vector< std::string > & |
global_defines_to_add, |
|
|
const std::vector< std::string > & |
global_defines_to_omit |
|
) |
| |
Recalculates the defines of this shader, and marks dirty if they differ from the last Reload().
Defines change the shader source code when it is preprocessed. Typically, you have one uber-shader that contains all possible shader features, and enable the features using preprocessor defines. This function allows you to specify which features are enabled.
- Note
- This function does not reload the shader. It will simply mark the shader as dirty, if its defines have changed.
- Parameters
-
global_defines_to_add | the defines to be added into 'local_defines' above. These are generally global rendering settings, for example, enabling shadows or specular. |
global_defines_to_omit | the defines to forcefully omit from 'local_defines'. Generally used to globally disable expensive features such as shadows, on low-powered hardware. |