Allow tracks and library objects to use custom shader

This commit is contained in:
Benau 2018-01-22 10:34:49 +08:00
parent 0ed74ac3e9
commit 39f4f8e966
2 changed files with 17 additions and 0 deletions

View File

@ -40,11 +40,13 @@
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/render_target.hpp"
#include "graphics/shader_files_manager.hpp"
#include "graphics/stk_tex_manager.hpp"
#include "graphics/sp/sp_base.hpp"
#include "graphics/sp/sp_mesh.hpp"
#include "graphics/sp/sp_mesh_buffer.hpp"
#include "graphics/sp/sp_mesh_node.hpp"
#include "graphics/sp/sp_shader_manager.hpp"
#include "graphics/sp/sp_texture_manager.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
@ -424,6 +426,8 @@ void Track::cleanup()
if (CVS->isGLSL())
{
SP::SPShaderManager::get()->removeUnusedShaders();
ShaderFilesManager::getInstance()->removeUnusedShaderFiles();
SP::SPTextureManager::get()->removeUnusedTextures();
}
#endif
@ -1739,6 +1743,12 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
// Add the track directory to the texture search path
file_manager->pushTextureSearchPath(m_root, unique_id);
file_manager->pushModelSearchPath(m_root);
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
SP::SPShaderManager::get()->loadSPShaders(m_root);
}
#endif
// First read the temporary materials.xml file if it exists
try

View File

@ -30,6 +30,7 @@
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/stk_particle.hpp"
#include "graphics/sp/sp_shader_manager.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "input/device_manager.hpp"
@ -242,6 +243,12 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
file_manager->pushTextureSearchPath(lib_path + "/", unique_id);
file_manager->pushModelSearchPath(lib_path);
material_manager->pushTempMaterial(lib_path + "/materials.xml");
#ifndef SERVER_ONLY
if (CVS->isGLSL())
{
SP::SPShaderManager::get()->loadSPShaders(lib_path);
}
#endif
model_def_loader.addToLibrary(name, libroot);
// Load LOD groups