|
|
|
|
|
When prototyping an application it can help if the shaders can be reloaded at runtime so that the app doesn't have to be restarted for each change. For this the ShaderProgramFileManager can be used. It will hold a shared pointer to all shaders and can be asked to reload all shader programs. To use this feature, all shader programs in question have to be loaded by the manager:
|
|
|
|
|
|
// old code:
|
|
|
SharedShaderProgram myShader = ShaderProgramCreator("myShaderFileName").create();
|
|
|
|
|
|
// new code:
|
|
|
ConstSharedShaderProgram myShader = ShaderProgramFileManager::the()->get( ShaderProgramCreator("myShaderFileName") );
|
|
|
|
|
|
Note that .create() was not called explicitly as the Manager will call it implicitly. The Manager can be found in #include <ACGL/OpenGL/Managers.hh>.
|
|
|
|
|
|
To reload the shader programs simply call ShaderProgramFileManager::the()->updateAll(); every couple of frames. It will check if the edit time of the used shader files changed and only reload if that was the case. It will also try to keep the old shader program in case the new file could not get compiled or linked due to syntax errors. Note that set uniform (including textures) are not restored for the reloaded shader so set them on your own afterward.
|
|
|
|
|
|
Similar reload manager are available for textures and meshes as well. |
|
|
\ No newline at end of file |