From 37d821dcc326b88c5f2967226d72ade9790fbbdf Mon Sep 17 00:00:00 2001 From: cutealien Date: Mon, 24 Apr 2023 16:01:13 +0000 Subject: [PATCH] Add MaterialType in COpenGLSLMaterialRenderer::OnSetMaterial back in Shouldn't have been removed with last commit. But adding some comments as it's slightly confusing. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6470 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/COpenGLSLMaterialRenderer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp index f506a45..df2cb06 100644 --- a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp +++ b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp @@ -237,10 +237,13 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(const video::SMaterial& material, COpenGLCacheHandler* cacheHandler = Driver->getCacheHandler(); - if (Program2) - Driver->irrGlUseProgram(Program2); - else if (Program) - Driver->extGlUseProgramObject(Program); + if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) // each program has it's own type + { + if (Program2) + Driver->irrGlUseProgram(Program2); + else if (Program) + Driver->extGlUseProgramObject(Program); + } Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);