Преглед изворни кода

improve error if canvas is null or undefined.

Steve Ognibene пре 8 година
родитељ
комит
3d54055257
2 измењених фајлова са 6 додато и 0 уклоњено
  1. 3 0
      src/babylon.engine.js
  2. 3 0
      src/babylon.engine.ts

+ 3 - 0
src/babylon.engine.js

@@ -214,6 +214,9 @@ var BABYLON;
             //    // Do nothing
             //}
             if (!this._gl) {
+                if (!canvas) {
+                    throw new Error("The provided canvas is null or undefined.");
+                }
                 try {
                     this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
                 }

+ 3 - 0
src/babylon.engine.ts

@@ -518,6 +518,9 @@
             //}
 
             if (!this._gl) {
+                if (!canvas) {
+                    throw new Error("The provided canvas is null or undefined.");
+                }
                 try {
                     this._gl = <WebGLRenderingContext>(canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
                 } catch (e) {