Skip to content

Commit

Permalink
Clarified console messages relating to WebGL support (#775)
Browse files Browse the repository at this point in the history
Updated console message emitted during WorldWindow construction when a WebGL context cannot be created. These messages appear when the browser does not support WebGL, or when WebGL support has been disabled (either by the user, or by a group policy).
  • Loading branch information
pdavidc authored and markpet49 committed Jul 16, 2018
1 parent fd819ab commit 6e3858d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/WorldWindow.js
Expand Up @@ -84,8 +84,7 @@ define([
var WorldWindow = function (canvasElem, elevationModel) {
if (!(window.WebGLRenderingContext)) {
throw new ArgumentError(
Logger.logMessage(Logger.LEVEL_SEVERE, "WorldWindow", "constructor",
"The specified canvas does not support WebGL."));
Logger.logMessage(Logger.LEVEL_SEVERE, "WorldWindow", "constructor", "webglNotSupported"));
}

// Get the actual canvas element either directly or by ID.
Expand All @@ -105,6 +104,10 @@ define([

// Create the WebGL context associated with the HTML canvas.
var gl = this.createContext(canvas);
if (!gl) {
throw new ArgumentError(
Logger.logMessage(Logger.LEVEL_SEVERE, "WorldWindow", "constructor", "webglNotSupported"));
}

// Internal. Intentionally not documented.
this.drawContext = new DrawContext(gl);
Expand All @@ -124,6 +127,9 @@ define([
// Internal. Intentionally not documented.
this.scratchProjection = Matrix.fromIdentity();

// Internal. Intentionally not documented.
this.hasStencilBuffer = gl.getContextAttributes().stencil;

/**
* The HTML canvas associated with this WorldWindow.
* @type {HTMLElement}
Expand Down Expand Up @@ -564,9 +570,6 @@ define([
gl = canvas.getContext("experimental-webgl", glAttrs);
}

var actualAttributes = gl.getContextAttributes();
this.hasStencilBuffer = actualAttributes.stencil;

// uncomment to debug WebGL
//var gl = WebGLDebugUtils.makeDebugContext(this.canvas.getContext("webgl"),
// this.throwOnGLError,
Expand Down
3 changes: 2 additions & 1 deletion src/util/Logger.js
Expand Up @@ -161,7 +161,8 @@ define(function () {
missingWebCoverageService: "The specified WebCoverageService is null or undefined.",
missingWorldWindow: "The specified WorldWindow is null or undefined.",
notYetImplemented: "This function is not yet implemented",
unsupportedVersion: "The specified version is not supported."
unsupportedVersion: "The specified version is not supported.",
webglNotSupported: "The browser does not support WebGL, or WebGL is disabled."
}
};

Expand Down

0 comments on commit 6e3858d

Please sign in to comment.