diff options
author | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:18:21 +0000 |
---|---|---|
committer | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 21:18:21 +0000 |
commit | c76b22663b8aef4a9f739b6a72a561cc866567f9 (patch) | |
tree | eb8c8ea4b18073f7e7b9fd6aca1f6c4c1e727bab /o3d/samples/o3d-webgl/client.js | |
parent | 53329586a1a78bbe8052f172dea5f865dfa78c60 (diff) | |
download | chromium_src-c76b22663b8aef4a9f739b6a72a561cc866567f9.zip chromium_src-c76b22663b8aef4a9f739b6a72a561cc866567f9.tar.gz chromium_src-c76b22663b8aef4a9f739b6a72a561cc866567f9.tar.bz2 |
When a demo on the o3d-webgl site gets opened in an ordinary browser that doesn't support WebGL yet, the error message just says "WebGL context not found". Now it provides a link with more information.
Review URL: http://codereview.chromium.org/2099002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47312 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3d-webgl/client.js')
-rw-r--r-- | o3d/samples/o3d-webgl/client.js | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/o3d/samples/o3d-webgl/client.js b/o3d/samples/o3d-webgl/client.js index b580215..cef816b 100644 --- a/o3d/samples/o3d-webgl/client.js +++ b/o3d/samples/o3d-webgl/client.js @@ -192,6 +192,15 @@ o3d.ClientInfo.prototype.software_renderer = false; o3d.ClientInfo.prototype.non_power_of_two_textures = true; + +/** + * True if shaders need to be GLSL instead of Cg/HLSL. + * In this implementation of o3d, that is true by default. + **/ +o3d.ClientInfo.prototype.glsl = true; + + + /** * The Client class is the main point of entry to O3D. It defines methods * for creating and deleting packs. Each new object created by the Client is @@ -209,6 +218,7 @@ o3d.Client = function() { this.renderGraphRoot = tempPack.createObject('RenderNode'); this.clientId = o3d.Client.nextId++; this.packs_ = [tempPack]; + this.clientInfo = tempPack.createObject('ClientInfo'); if (o3d.Renderer.clients_.length == 0) o3d.Renderer.installRenderInterval(); @@ -574,6 +584,7 @@ o3d.Client.prototype.__defineSetter__('height', /** * Initializes this client using the canvas. * @param {Canvas} + * @return {boolean} Success. */ o3d.Client.prototype.initWithCanvas = function(canvas) { var gl; @@ -586,16 +597,22 @@ o3d.Client.prototype.initWithCanvas = function(canvas) { premultipliedAlpha : true }; + if (!canvas || !canvas.getContext) { + return false; + } try {gl = canvas.getContext("experimental-webgl", standard_attributes) } catch(e) { } - if (!gl) - try {gl = canvas.getContext("moz-webgl") } catch(e) { } if (!gl) { - alert("No WebGL context found"); - return null; + try { + gl = canvas.getContext("moz-webgl") + } catch(e) { } } - // TODO(petersont): hack workaround for WebGLRenderingContext.canvas - // not being implemented in Firefox. Remove. + if (!gl) { + return false; + } + + // TODO(petersont): Remove this workaround once WebGLRenderingContext.canvas + // is implemented in Firefox. gl.hack_canvas = canvas; this.gl = gl; this.root.gl = gl; @@ -604,6 +621,8 @@ o3d.Client.prototype.initWithCanvas = function(canvas) { gl.client = this; gl.displayInfo = {width: canvas.width, height: canvas.height}; + + return true; }; @@ -1076,6 +1095,12 @@ o3d.Client.prototype.clientId = 0; /** + * Gets info about the client. + */ +o3d.Client.prototype.clientInfo = null; + + +/** * The canvas associated with this client. * @type {Element} */ |