summaryrefslogtreecommitdiffstats
path: root/o3d/samples/o3djs/webgl.js
diff options
context:
space:
mode:
authorpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 21:45:34 +0000
committerpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 21:45:34 +0000
commit9d7a5dded02f75bbf4dce8857d871d8d18d9c9ac (patch)
tree717f3760e42042a470d9b11cc28a02d4e02e162a /o3d/samples/o3djs/webgl.js
parentf0dfb8223d5a73cacd2dbaafdd890adec101d5c7 (diff)
downloadchromium_src-9d7a5dded02f75bbf4dce8857d871d8d18d9c9ac.zip
chromium_src-9d7a5dded02f75bbf4dce8857d871d8d18d9c9ac.tar.gz
chromium_src-9d7a5dded02f75bbf4dce8857d871d8d18d9c9ac.tar.bz2
Modified effect.js to emit glsl as well as the original o3d shader language. Also got primitives.html working and added it to o3d-webgl-samples directory.
Review URL: http://codereview.chromium.org/1300002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43884 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3djs/webgl.js')
-rw-r--r--o3d/samples/o3djs/webgl.js31
1 files changed, 21 insertions, 10 deletions
diff --git a/o3d/samples/o3djs/webgl.js b/o3d/samples/o3djs/webgl.js
index 1bbe168..3f4c1f5 100644
--- a/o3d/samples/o3djs/webgl.js
+++ b/o3d/samples/o3djs/webgl.js
@@ -38,8 +38,10 @@
o3djs.provide('o3djs.webgl');
+o3djs.require('o3djs.effect');
o3djs.require('o3djs.util');
+
/**
* A Module with various utilities.
* @namespace
@@ -52,11 +54,12 @@ o3djs.webgl = o3djs.webgl || {};
* under them with o3d client object and the o3d namespace.
*/
o3djs.webgl.makeClients = function(callback,
- opt_features,
- opt_requiredVersion,
- opt_failureCallback,
- opt_id,
- opt_tag) {
+ opt_features,
+ opt_requiredVersion,
+ opt_failureCallback,
+ opt_id,
+ opt_tag,
+ opt_debug) {
opt_failureCallback = opt_failureCallback || o3djs.webgl.informPluginFailure;
var clientElements = [];
@@ -73,7 +76,7 @@ o3djs.webgl.makeClients = function(callback,
features = '';
}
}
- var objElem = o3djs.webgl.createClient(element, features);
+ var objElem = o3djs.webgl.createClient(element, features, opt_debug);
clientElements.push(objElem);
}
@@ -92,12 +95,14 @@ o3djs.webgl.createGLErrorWrapper = function(context, fname) {
return function() {
var rv = context[fname].apply(context, arguments);
var err = context.getError();
- if (err != 0)
+ if (err != 0) {
throw "GL error " + err + " in " + fname;
+ }
return rv;
};
};
+
/**
* Adds a wrapper object to a webgl context that checks for errors
* before each function call.
@@ -108,7 +113,7 @@ o3djs.webgl.addDebuggingWrapper = function(context) {
var wrap = {};
for (var i in context) {
if (typeof context[i] == 'function') {
- wrap[i] = createGLErrorWrapper(context, i);
+ wrap[i] = o3djs.webgl.createGLErrorWrapper(context, i);
} else {
wrap[i] = context[i];
}
@@ -133,13 +138,19 @@ o3djs.webgl.createClient = function(element, opt_features, opt_debug) {
opt_features = opt_features || '';
opt_debug = opt_debug || false;
+ // If we're creating a webgl client, the assumption is we're using webgl,
+ // in which case the only acceptable shader language is glsl. So, here
+ // we set the shader language to glsl.
+ o3djs.effect.setLanguage('glsl');
+
var canvas;
canvas = document.createElement('canvas');
canvas.setAttribute('width', element.getAttribute('width'));
canvas.setAttribute('height', element.getAttribute('height'));
- canvas.client = new o3d.Client;
- canvas.client.initWithCanvas(canvas);
+ var client = new o3d.Client;
+ client.initWithCanvas(canvas);
+ canvas.client = client;
canvas.o3d = o3d;
if (opt_debug) {