Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: samples/o3d-webgl/client.js

Issue 2099002: Better error message when WebGL not found. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: '' Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | samples/o3djs/webgl.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/o3d-webgl/client.js
===================================================================
--- samples/o3d-webgl/client.js (revision 46638)
+++ samples/o3d-webgl/client.js (working copy)
@@ -192,7 +192,16 @@
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
* assigned a unique ID.
@@ -209,6 +218,7 @@
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 @@
/**
* Initializes this client using the canvas.
* @param {Canvas}
+ * @return {boolean} Success.
*/
o3d.Client.prototype.initWithCanvas = function(canvas) {
var gl;
@@ -586,16 +597,22 @@
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 @@
gl.client = this;
gl.displayInfo = {width: canvas.width,
height: canvas.height};
+
+ return true;
};
@@ -1076,6 +1095,12 @@
/**
+ * Gets info about the client.
+ */
+o3d.Client.prototype.clientInfo = null;
+
+
+/**
* The canvas associated with this client.
* @type {Element}
*/
« no previous file with comments | « no previous file | samples/o3djs/webgl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698