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
master
hybrid 2008-04-30 17:06:08 +00:00
parent 376c58fe28
commit 7bfe4830d2
2 changed files with 13 additions and 6 deletions

View File

@ -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);

View File

@ -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