Add a function that kills shaders and use it when reloading shader.

Thus there is no mesh corruption.
This commit is contained in:
Vincent Lejeune 2014-08-21 02:19:33 +02:00
parent 5abc404ed9
commit d968ce11bf
4 changed files with 9 additions and 5 deletions

View File

@ -736,7 +736,7 @@ void IrrDriver::applyResolutionSettings()
// FIXME: this load sequence is (mostly) duplicated from main.cpp!!
// That's just error prone
// (we're sure to update main.cpp at some point and forget this one...)
m_shaders->killShaders();
// initDevice will drop the current device.
initDevice();

View File

@ -570,7 +570,7 @@ public:
// -----------------------------------------------------------------------
inline video::E_MATERIAL_TYPE getShader(const ShaderType num) {return m_shaders->getShader(num);}
// -----------------------------------------------------------------------
inline void updateShaders() {m_shaders->loadShaders();}
inline void updateShaders() {m_shaders->killShaders();}
// ------------------------------------------------------------------------
inline video::IShaderConstantSetCallBack* getCallback(const ShaderType num)
{

View File

@ -399,9 +399,6 @@ void Shaders::loadShaders()
}
initGL();
// Clean alive shaders
for (unsigned i = 0; i < CleanTable.size(); i++)
CleanTable[i]();
CleanTable.clear();
initQuadVBO();
initQuadBuffer();
@ -418,6 +415,12 @@ void Shaders::loadShaders()
UtilShader::ColoredLine::init();
}
void Shaders::killShaders()
{
for (unsigned i = 0; i < CleanTable.size(); i++)
CleanTable[i]();
}
Shaders::~Shaders()
{
u32 i;

View File

@ -1039,6 +1039,7 @@ public:
video::IShaderConstantSetCallBack * m_callbacks[ES_COUNT];
void loadShaders();
void killShaders();
private:
void check(const int num) const;