Skip to content

Commit 3696f73

Browse files
committed
Guard against missing shaders.
1 parent 60e6eff commit 3696f73

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/renderer/webgl/WebGLPipeline.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,10 @@ var WebGLPipeline = new Class({
598598

599599
if (len === 0)
600600
{
601-
this.shaders = [ new WebGLShader(this, 'default', defaultVertShader, defaultFragShader, DeepCopy(defaultAttribs), DeepCopy(defaultUniforms)) ];
601+
if (defaultVertShader && defaultFragShader)
602+
{
603+
this.shaders = [ new WebGLShader(this, 'default', defaultVertShader, defaultFragShader, DeepCopy(defaultAttribs), DeepCopy(defaultUniforms)) ];
604+
}
602605
}
603606
else
604607
{
@@ -615,13 +618,23 @@ var WebGLPipeline = new Class({
615618
var attributes = GetFastValue(shaderEntry, aName, defaultAttribs);
616619
var uniforms = GetFastValue(shaderEntry, uName, defaultUniforms);
617620

618-
newShaders.push(new WebGLShader(this, name, vertShader, fragShader, DeepCopy(attributes), DeepCopy(uniforms)));
621+
if (vertShader && fragShader)
622+
{
623+
newShaders.push(new WebGLShader(this, name, vertShader, fragShader, DeepCopy(attributes), DeepCopy(uniforms)));
624+
}
619625
}
620626

621627
this.shaders = newShaders;
622628
}
623629

624-
this.currentShader = this.shaders[0];
630+
if (this.shaders.length === 0)
631+
{
632+
console.warn('Pipeline: ' + this.name + ' - Invalid shader config');
633+
}
634+
else
635+
{
636+
this.currentShader = this.shaders[0];
637+
}
625638

626639
return this;
627640
},

0 commit comments

Comments
 (0)