summaryrefslogtreecommitdiffstats
path: root/o3d/samples/o3d-webgl
diff options
context:
space:
mode:
Diffstat (limited to 'o3d/samples/o3d-webgl')
-rw-r--r--o3d/samples/o3d-webgl/client.js13
-rw-r--r--o3d/samples/o3d-webgl/pack.js10
-rw-r--r--o3d/samples/o3d-webgl/render_surface_set.js8
-rw-r--r--o3d/samples/o3d-webgl/texture.js5
4 files changed, 24 insertions, 12 deletions
diff --git a/o3d/samples/o3d-webgl/client.js b/o3d/samples/o3d-webgl/client.js
index 62ec060..04fed36 100644
--- a/o3d/samples/o3d-webgl/client.js
+++ b/o3d/samples/o3d-webgl/client.js
@@ -543,13 +543,13 @@ o3d.Client.prototype.fullscreen = false;
*/
o3d.Client.prototype.__defineGetter__('width',
function() {
- return this.gl.canvas.width;
+ return this.gl.hack_canvas.width;
}
);
o3d.Client.prototype.__defineSetter__('width',
function(x) {
- this.gl.canvas.width = x;
+ this.gl.hack_canvas.width = x;
}
);
@@ -560,13 +560,13 @@ o3d.Client.prototype.__defineSetter__('width',
*/
o3d.Client.prototype.__defineGetter__('height',
function() {
- return this.gl.canvas.height;
+ return this.gl.hack_canvas.height;
}
);
o3d.Client.prototype.__defineSetter__('height',
function(x) {
- this.gl.canvas.height = x;
+ this.gl.hack_canvas.height = x;
}
);
@@ -594,6 +594,9 @@ o3d.Client.prototype.initWithCanvas = function(canvas) {
return null;
}
+ // TODO(petersont): hack workaround for WebGLRenderingContext.canvas
+ // not being implemented in Firefox. Remove.
+ gl.hack_canvas = canvas;
this.gl = gl;
this.root.gl = gl;
this.renderGraphRoot.gl = gl;
@@ -710,7 +713,7 @@ o3d.Client.prototype.clearLostResourcesCallback =
*/
o3d.Client.prototype.setEventCallback =
function(type, handler) {
- var listener = this.gl.canvas;
+ var listener = this.gl.hack_canvas;
// TODO(petersont): Figure out a way for a canvas to listen to a key event
// directly.
if (type.substr(0, 3) == 'key') {
diff --git a/o3d/samples/o3d-webgl/pack.js b/o3d/samples/o3d-webgl/pack.js
index a5336ea..78ec5ee 100644
--- a/o3d/samples/o3d-webgl/pack.js
+++ b/o3d/samples/o3d-webgl/pack.js
@@ -210,8 +210,11 @@ o3d.Pack.prototype.createTexture2D =
if (width != undefined && height != undefined) {
this.gl.bindTexture(this.gl.TEXTURE_2D, texture.texture_);
+ // TODO(petersont): remove this allocation once Firefox supports
+ // passing null as argument to this form of texImage2D.
+ var t = new WebGLUnsignedByteArray(width * height * 4);
this.gl.texImage2D(this.gl.TEXTURE_2D, 0, this.gl.RGBA, width, height,
- 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, null);
+ 0, this.gl.RGBA, this.gl.UNSIGNED_BYTE, t);
}
return texture;
@@ -241,10 +244,13 @@ o3d.Pack.prototype.createTextureCUBE =
texture.texture_target_ = this.gl.TEXTURE_CUBE_MAP;
this.gl.bindTexture(this.gl.TEXTURE_CUBE_MAP, texture.texture_);
+ // TODO(petersont): remove this allocation once Firefox supports
+ // passing null as argument to this form of texImage2D.
+ var t = new WebGLUnsignedByteArray(edgeLength * edgeLength * 4);
for (var ii = 0; ii < 6; ++ii) {
this.gl.texImage2D(this.gl.TEXTURE_CUBE_MAP_POSITIVE_X + ii,
0, this.gl.RGBA, edgeLength, edgeLength, 0,
- this.gl.RGBA, this.gl.UNSIGNED_BYTE, null);
+ this.gl.RGBA, this.gl.UNSIGNED_BYTE, t);
}
this.gl.texParameteri(this.gl.TEXTURE_CUBE_MAP,
this.gl.TEXTURE_MAG_FILTER, this.gl.LINEAR);
diff --git a/o3d/samples/o3d-webgl/render_surface_set.js b/o3d/samples/o3d-webgl/render_surface_set.js
index 9484e9c..694e290 100644
--- a/o3d/samples/o3d-webgl/render_surface_set.js
+++ b/o3d/samples/o3d-webgl/render_surface_set.js
@@ -39,7 +39,7 @@
* 1) If both a color and depth surface is bound, then they must be of
* matching dimensions.
* 2) At least one of render_surface and render_depth_surface must non-null.
- *
+ *
* @param {o3d.RenderSurface} opt_renderSurface The render surface to set.
* @param {o3d.RenderDepthStencilSurface} opt_renderDepthStencilSurface The
* depth stencil render surface to set.
@@ -86,15 +86,15 @@ o3d.RenderSurfaceSet.prototype.clearFramebufferObjects_ =
this.gl.FRAMEBUFFER,
this.gl.COLOR_ATTACHMENT0,
this.gl.RENDERBUFFER,
- 0);
+ null);
this.gl.framebufferRenderbuffer(
this.gl.FRAMEBUFFER,
this.gl.DEPTH_ATTACHMENT,
this.gl.RENDERBUFFER,
- 0);
+ null);
- this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, 0);
+ this.gl.bindFramebuffer(this.gl.FRAMEBUFFER, null);
};
diff --git a/o3d/samples/o3d-webgl/texture.js b/o3d/samples/o3d-webgl/texture.js
index 7cc7927..1e63744 100644
--- a/o3d/samples/o3d-webgl/texture.js
+++ b/o3d/samples/o3d-webgl/texture.js
@@ -367,7 +367,10 @@ o3d.Texture2D.prototype.drawImage =
0, 0, source_img.canvas_.width, source_img.canvas_.height);
this.gl.bindTexture(this.gl.TEXTURE_2D, this.texture_);
- this.gl.texSubImage2D(this.gl.TEXTURE_2D, 0, 0, 0, canvas);
+ // TODO(petersont): replace this with a call to texSubImage2D once
+ // Firefox supports it.
+ this.gl.texImage2D(this.gl.TEXTURE_2D, 0, canvas);
+ // this.gl.texSubImage2D(this.gl.TEXTURE_2D, 0, 0, 0, canvas);
};