From 7bfe4830d29b3925c3e37902f29342b3074e4eae Mon Sep 17 00:00:00 2001 From: hybrid Date: Wed, 30 Apr 2008 17:06:08 +0000 Subject: [PATCH] Fixed cleanup in case of failed shader compilation such that the base material is used. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1344 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/COpenGLDriver.cpp | 4 ++-- source/Irrlicht/COpenGLShaderMaterialRenderer.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index ce62b2d0..b4f0a7e1 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -354,8 +354,8 @@ void COpenGLDriver::createMaterialRenderers() { // create OpenGL material renderers - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID( this)); - addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID_2_LAYER( this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID(this)); + addAndDropMaterialRenderer(new COpenGLMaterialRenderer_SOLID_2_LAYER(this)); // add the same renderer for all lightmap types COpenGLMaterialRenderer_LIGHTMAP* lmr = new COpenGLMaterialRenderer_LIGHTMAP( this); diff --git a/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp b/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp index bebe2923..9b288f28 100644 --- a/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp +++ b/source/Irrlicht/COpenGLShaderMaterialRenderer.cpp @@ -78,12 +78,13 @@ void COpenGLShaderMaterialRenderer::init(s32& outMaterialTypeNr, const c8* verte { outMaterialTypeNr = -1; + bool failure; + // create vertex shader - if (!createVertexShader(vertexShaderProgram)) - return; + failure=createVertexShader(vertexShaderProgram); // create pixel shader - if (!createPixelShader(pixelShaderProgram)) + if (!createPixelShader(pixelShaderProgram) || failure) return; // register as a new material @@ -194,6 +195,9 @@ bool COpenGLShaderMaterialRenderer::createPixelShader(const c8* pxsh) sprintf(tmp, "Pixel shader compilation failed at position %d:\n%s", errPos, errString); os::Printer::log(tmp); + Driver->extGlDeletePrograms(1, &PixelShader); + PixelShader=0; + return false; } #else @@ -215,7 +219,7 @@ bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh) // clear error buffer while(glGetError() != GL_NO_ERROR) - {} + {} // compile Driver->extGlProgramString(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, @@ -233,6 +237,9 @@ bool COpenGLShaderMaterialRenderer::createVertexShader(const char* vtxsh) sprintf(tmp, "Vertex shader compilation failed at position %d:\n%s", errPos, errString); os::Printer::log(tmp); + Driver->extGlDeletePrograms(1, &VertexShader); + VertexShader=0; + return false; } #else