summaryrefslogtreecommitdiffstats
path: root/o3d/samples/o3d-webgl
diff options
context:
space:
mode:
authorkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 22:01:10 +0000
committerkbr@google.com <kbr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 22:01:10 +0000
commit1e08646c43e6a02f6dfb69de395f5394097a7fb8 (patch)
tree06773af312b136c7f32973e4aae024f1cf44aeae /o3d/samples/o3d-webgl
parent182434efa19ed7aaf0d7ce0b3164003174553cb7 (diff)
downloadchromium_src-1e08646c43e6a02f6dfb69de395f5394097a7fb8.zip
chromium_src-1e08646c43e6a02f6dfb69de395f5394097a7fb8.tar.gz
chromium_src-1e08646c43e6a02f6dfb69de395f5394097a7fb8.tar.bz2
Fixed problem in o3dConverter where it was not outputting all of the
vertex data in JSON format. Fixed problems in effect.js where GLSL code path needed to name the texture coordinate attributes with the semantic names and not the names like "diffuseUV" because otherwise the backend did not know how to hook them up. Fixed problem with cube map faces being flipped and bug in binding cube map textures. At this point o3d-webgl can load the converted cube and teapot, though the teapot is currently missing the bump map. Tested O3D plugin with this sample to ensure no regression. BUG=none TEST=none Review URL: http://codereview.chromium.org/1729012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45495 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3d-webgl')
-rw-r--r--o3d/samples/o3d-webgl/client.js9
-rw-r--r--o3d/samples/o3d-webgl/pack.js11
-rw-r--r--o3d/samples/o3d-webgl/param.js4
-rw-r--r--o3d/samples/o3d-webgl/texture.js10
4 files changed, 24 insertions, 10 deletions
diff --git a/o3d/samples/o3d-webgl/client.js b/o3d/samples/o3d-webgl/client.js
index 4e13450..fb54b79 100644
--- a/o3d/samples/o3d-webgl/client.js
+++ b/o3d/samples/o3d-webgl/client.js
@@ -752,7 +752,12 @@ o3d.Client.prototype.clearTickCallback = function() {
*/
o3d.Client.prototype.setErrorCallback =
function(error_callback) {
- this.error_callback = error_callback;
+ // Other code expects to not see a null error callback.
+ if (error_callback) {
+ this.error_callback = error_callback;
+ } else {
+ this.error_callback = function(string) {};
+ }
};
@@ -764,7 +769,7 @@ o3d.Client.prototype.setErrorCallback =
* time or if you call ClearErrorCallback.
*/
o3d.Client.prototype.clearErrorCallback = function() {
- this.error_callback = null;
+ this.setErrorCallback(null);
};
diff --git a/o3d/samples/o3d-webgl/pack.js b/o3d/samples/o3d-webgl/pack.js
index a9f79bb..4a72feb 100644
--- a/o3d/samples/o3d-webgl/pack.js
+++ b/o3d/samples/o3d-webgl/pack.js
@@ -205,6 +205,7 @@ o3d.Pack.prototype.createTexture2D =
texture.height = height;
texture.levels = levels;
texture.texture_ = this.gl.createTexture();
+ texture.texture_target_ = this.gl.TEXTURE_2D;
if (width != undefined && height != undefined) {
this.gl.bindTexture(this.gl.TEXTURE_2D, texture.texture_);
@@ -246,6 +247,7 @@ o3d.Pack.prototype.createTextureCUBE =
var texture = this.createObject('TextureCUBE');
texture.edgeLength = edgeLength;
texture.texture_ = this.gl.createTexture();
+ texture.texture_target_ = this.gl.TEXTURE_CUBE_MAP;
this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, texture.texture_);
for (var ii = 0; ii < 6; ++ii) {
@@ -412,15 +414,14 @@ o3d.Pack.prototype.createBitmapsFromRawData =
canvas.width = bitmap.width;
canvas.height = bitmap.height;
-
- bitmap.canvas_ = canvas;
var context = canvas.getContext('2d');
- // Flip it.
- context.translate(0, bitmap.height);
- context.scale(1, -1);
context.drawImage(raw_data.image_,
0, 0, bitmap.width, bitmap.height);
+ bitmap.canvas_ = canvas;
+ // Most images require a vertical flip.
+ bitmap.flipVertically();
+
// TODO(petersont): I'm not sure how to get the format.
bitmap.format = o3d.Texture.ARGB8;
bitmap.numMipmaps = 1;
diff --git a/o3d/samples/o3d-webgl/param.js b/o3d/samples/o3d-webgl/param.js
index a32d004..731ae21 100644
--- a/o3d/samples/o3d-webgl/param.js
+++ b/o3d/samples/o3d-webgl/param.js
@@ -820,12 +820,14 @@ o3d.ParamSampler.prototype.applyToLocation = function(gl, location) {
gl.activeTexture(gl.TEXTURE0 + i);
var value = null;
+ var target = 0;
if (this.value && this.value.texture && this.value.texture.texture_) {
value = this.value.texture.texture_;
+ target = this.value.texture.texture_target_;
}
- gl.bindTexture(gl.TEXTURE_2D, value);
+ gl.bindTexture(target, value);
gl.uniform1i(location, i);
o3d.Param.texture_index_++;
};
diff --git a/o3d/samples/o3d-webgl/texture.js b/o3d/samples/o3d-webgl/texture.js
index 53214d0..9f5db11 100644
--- a/o3d/samples/o3d-webgl/texture.js
+++ b/o3d/samples/o3d-webgl/texture.js
@@ -57,12 +57,18 @@ o3d.Texture = function() {
this.alphaIsOne = true;
/**
- * The the associated gl texture.
+ * The associated gl texture.
* @type {WebGLTexture}
* @private
*/
this.texture_ = null;
+ /**
+ * The associated GL texture target: TEXTURE_2D or TEXTURE_CUBE_MAP.
+ * @type {number}
+ * @private
+ */
+ this.texture_target_ = 0;
};
o3d.inherit('Texture', 'ParamObject');
@@ -274,7 +280,7 @@ o3d.Texture2D.prototype.setFromBitmap =
this.gl.texImage2D(this.gl.TEXTURE_2D,
0, // Level.
bitmap.canvas_,
- bitmap.defer_flip_verically_to_texture_);
+ bitmap.defer_flip_vertically_to_texture_);
if (bitmap.defer_mipmaps_to_texture_) {
this.generateMips();
}