diff --git a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js index 5dfb17f..be19ee5 100644 --- a/src/core/renderers/webgl/systems/geometry/GeometrySystem.js +++ b/src/core/renderers/webgl/systems/geometry/GeometrySystem.js @@ -26,6 +26,7 @@ this._activeVao = null; this.hasVao = true; + this.hasInstance = true; } /** @@ -60,6 +61,19 @@ gl.deleteVertexArray = ()=>{} } } + + if(!gl.vertexAttribDivisor) + { + const instanceExt = gl.getExtension("ANGLE_instanced_arrays"); + + if(instanceExt) + { + gl.vertexAttribDivisor = instanceExt.vertexAttribDivisorANGLE; + gl.drawElementsInstanced = instanceExt.drawElementsInstancedANGLE; + gl.drawArrayInstanced = instanceExt.drawArraysInstancedANGLE; + } + } + } /** @@ -293,7 +307,14 @@ if(attribute.instance) { - gl.vertexAttribDivisor(location, 1); + if(this.hasInstance) + { + gl.vertexAttribDivisor(location, 1); + } + else + { + throw new Error('geometry error, GPU Instancing is not supported on this device'); + } } } }