[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.16-1409-g5afdf4d
oliver at apple.com
oliver at apple.com
Thu Dec 3 13:30:51 UTC 2009
The following commit has been merged in the webkit-1.1 branch:
commit 91a1f0f0bfaeb1a1e3008353c952089e462e86e9
Author: oliver at apple.com <oliver at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Nov 10 09:57:29 2009 +0000
Fix WebGL demos to work with renamed WebGL primitives
Reviewed by Maciej Stachowiak
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@50728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitSite/ChangeLog b/WebKitSite/ChangeLog
index 9f2e4e7..3083f99 100644
--- a/WebKitSite/ChangeLog
+++ b/WebKitSite/ChangeLog
@@ -1,3 +1,23 @@
+2009-11-10 Oliver Hunt <oliver at apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ Fix WebGL demos to work with renamed WebGL primitives
+
+ * blog-files/webgl/Earth.html:
+ * blog-files/webgl/ManyPlanetsDeep.html:
+ * blog-files/webgl/SpinningBox.html:
+ * blog-files/webgl/SpiritBox.html:
+ * blog-files/webgl/TeapotPerPixel.html:
+ * blog-files/webgl/TeapotPerVertex.html:
+ * blog-files/webgl/WebGL+CSS.html:
+ * blog-files/webgl/resources/CanvasMatrix.js:
+ (CanvasMatrix4.prototype.getAsWebGLFloatArray):
+ * blog-files/webgl/resources/utils3d.js:
+ (makeBox):
+ (makeSphere):
+ (doLoadObj):
+
2009-11-06 Dirk Schulze <krit at webkit.org>
Rubber stamped by Eric Seidel.
diff --git a/WebKitSite/blog-files/webgl/Earth.html b/WebKitSite/blog-files/webgl/Earth.html
index 0a2271f..587a07f 100644
--- a/WebKitSite/blog-files/webgl/Earth.html
+++ b/WebKitSite/blog-files/webgl/Earth.html
@@ -105,18 +105,18 @@
mvMatrix.rotate(angle, 0,1,0);
mvMatrix.rotate(30, 1,0,0);
mvMatrix.translate(x,y,z);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsWebGLFloatArray());
// construct the normal matrix from the model-view matrix
var normalMatrix = new CanvasMatrix4(mvMatrix);
normalMatrix.invert();
normalMatrix.transpose();
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
// construct the model-view * projection matrix
var mvpMatrix = new CanvasMatrix4(mvMatrix);
mvpMatrix.multRight(ctx.perspectiveMatrix);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsWebGLFloatArray());
ctx.bindTexture(ctx.TEXTURE_2D, texture);
ctx.drawElements(ctx.TRIANGLES, ctx.sphere.numIndices, ctx.UNSIGNED_SHORT, 0);
diff --git a/WebKitSite/blog-files/webgl/ManyPlanetsDeep.html b/WebKitSite/blog-files/webgl/ManyPlanetsDeep.html
index 6657e7e..132e0d1 100644
--- a/WebKitSite/blog-files/webgl/ManyPlanetsDeep.html
+++ b/WebKitSite/blog-files/webgl/ManyPlanetsDeep.html
@@ -113,18 +113,18 @@
mvMatrix.rotate(angle, 0,1,0);
mvMatrix.rotate(30, 1,0,0);
mvMatrix.translate(x,y,z);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsWebGLFloatArray());
// construct the normal matrix from the model-view matrix
var normalMatrix = new CanvasMatrix4(mvMatrix);
normalMatrix.invert();
normalMatrix.transpose();
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
// construct the model-view * projection matrix
var mvpMatrix = new CanvasMatrix4(mvMatrix);
mvpMatrix.multRight(ctx.perspectiveMatrix);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvpMatrix.getAsWebGLFloatArray());
ctx.bindTexture(ctx.TEXTURE_2D, texture);
ctx.drawElements(ctx.TRIANGLES, ctx.sphere.numIndices, ctx.UNSIGNED_SHORT, 0);
diff --git a/WebKitSite/blog-files/webgl/SpinningBox.html b/WebKitSite/blog-files/webgl/SpinningBox.html
index b93ab76..7b8c5e7 100644
--- a/WebKitSite/blog-files/webgl/SpinningBox.html
+++ b/WebKitSite/blog-files/webgl/SpinningBox.html
@@ -45,7 +45,7 @@
gl.box = makeBox(gl);
// color array
- var colors = new CanvasUnsignedByteArray(
+ var colors = new WebGLUnsignedByteArray(
[ 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, // v0-v1-v2-v3 front
1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, // v0-v3-v4-v5 right
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, // v0-v5-v6-v1 top
@@ -77,7 +77,7 @@
var pMatrix = new CanvasMatrix4();
pMatrix.lookat(0,0,10, 0, 0, 0, 0, 1, 0);
pMatrix.perspective(30, width/height, 1, 10000);
- gl.uniformMatrix4fv(gl.getUniformLocation(gl.program, "pMatrix"), false, pMatrix.getAsCanvasFloatArray());
+ gl.uniformMatrix4fv(gl.getUniformLocation(gl.program, "pMatrix"), false, pMatrix.getAsWebGLFloatArray());
}
function drawPicture(gl)
@@ -88,7 +88,7 @@
var mvMatrix = new CanvasMatrix4();
mvMatrix.rotate(currentAngle, 0,1,0);
mvMatrix.rotate(20, 1,0,0);
- gl.uniformMatrix4fv(gl.getUniformLocation(gl.program, "mvMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ gl.uniformMatrix4fv(gl.getUniformLocation(gl.program, "mvMatrix"), false, mvMatrix.getAsWebGLFloatArray());
gl.enableVertexAttribArray(0);
gl.enableVertexAttribArray(1);
diff --git a/WebKitSite/blog-files/webgl/SpiritBox.html b/WebKitSite/blog-files/webgl/SpiritBox.html
index 3e6096f..ff67352 100644
--- a/WebKitSite/blog-files/webgl/SpiritBox.html
+++ b/WebKitSite/blog-files/webgl/SpiritBox.html
@@ -135,12 +135,12 @@
gl.normalMatrix.load(gl.mvMatrix);
gl.normalMatrix.invert();
gl.normalMatrix.transpose();
- gl.uniformMatrix4fv(gl.u_normalMatrixLoc, false, gl.normalMatrix.getAsCanvasFloatArray());
+ gl.uniformMatrix4fv(gl.u_normalMatrixLoc, false, gl.normalMatrix.getAsWebGLFloatArray());
// Construct the model-view * projection matrix and pass it in
gl.mvpMatrix.load(gl.mvMatrix);
gl.mvpMatrix.multRight(gl.perspectiveMatrix);
- gl.uniformMatrix4fv(gl.u_modelViewProjMatrixLoc, false, gl.mvpMatrix.getAsCanvasFloatArray());
+ gl.uniformMatrix4fv(gl.u_modelViewProjMatrixLoc, false, gl.mvpMatrix.getAsWebGLFloatArray());
// Bind the texture to use
gl.bindTexture(gl.TEXTURE_2D, spiritTexture);
diff --git a/WebKitSite/blog-files/webgl/TeapotPerPixel.html b/WebKitSite/blog-files/webgl/TeapotPerPixel.html
index 2d155af..b3f90ed 100644
--- a/WebKitSite/blog-files/webgl/TeapotPerPixel.html
+++ b/WebKitSite/blog-files/webgl/TeapotPerPixel.html
@@ -283,16 +283,16 @@
mvMatrix.makeIdentity();
mvMatrix.rotate(currentAngle, 0, 1, 0);
mvMatrix.rotate(10, 1,0,0);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsWebGLFloatArray());
// construct the normal matrix from the model-view matrix
normalMatrix.load(mvMatrix);
normalMatrix.invert();
normalMatrix.transpose();
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
mvMatrix.multRight(ctx.perspectiveMatrix);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsWebGLFloatArray());
ctx.drawElements(ctx.TRIANGLES, obj.numIndices, ctx.UNSIGNED_SHORT, 0);
diff --git a/WebKitSite/blog-files/webgl/TeapotPerVertex.html b/WebKitSite/blog-files/webgl/TeapotPerVertex.html
index 9c4c58d..6e90bf7 100644
--- a/WebKitSite/blog-files/webgl/TeapotPerVertex.html
+++ b/WebKitSite/blog-files/webgl/TeapotPerVertex.html
@@ -256,16 +256,16 @@
mvMatrix.makeIdentity();
mvMatrix.rotate(currentAngle, 0, 1, 0);
mvMatrix.rotate(10, 1,0,0);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsWebGLFloatArray());
// construct the normal matrix from the model-view matrix
normalMatrix.load(mvMatrix);
normalMatrix.invert();
normalMatrix.transpose();
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
mvMatrix.multRight(ctx.perspectiveMatrix);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsWebGLFloatArray());
ctx.drawElements(ctx.TRIANGLES, obj.numIndices, ctx.UNSIGNED_SHORT, 0);
diff --git a/WebKitSite/blog-files/webgl/WebGL+CSS.html b/WebKitSite/blog-files/webgl/WebGL+CSS.html
index b659f59..23e20a5 100644
--- a/WebKitSite/blog-files/webgl/WebGL+CSS.html
+++ b/WebKitSite/blog-files/webgl/WebGL+CSS.html
@@ -283,16 +283,16 @@
mvMatrix.makeIdentity();
mvMatrix.rotate(currentAngle, 0, 1, 0);
mvMatrix.rotate(10, 1,0,0);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewMatrix"), false, mvMatrix.getAsWebGLFloatArray());
// construct the normal matrix from the model-view matrix
normalMatrix.load(mvMatrix);
normalMatrix.invert();
normalMatrix.transpose();
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_normalMatrix"), false, normalMatrix.getAsWebGLFloatArray());
mvMatrix.multRight(ctx.perspectiveMatrix);
- ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsCanvasFloatArray());
+ ctx.uniformMatrix4fv(ctx.getUniformLocation(ctx.program, "u_modelViewProjMatrix"), false, mvMatrix.getAsWebGLFloatArray());
ctx.drawElements(ctx.TRIANGLES, obj.numIndices, ctx.UNSIGNED_SHORT, 0);
diff --git a/WebKitSite/blog-files/webgl/resources/CanvasMatrix.js b/WebKitSite/blog-files/webgl/resources/CanvasMatrix.js
index f35727f..19f9322 100644
--- a/WebKitSite/blog-files/webgl/resources/CanvasMatrix.js
+++ b/WebKitSite/blog-files/webgl/resources/CanvasMatrix.js
@@ -33,7 +33,7 @@
void load(in CanvasMatrix4 matrix); // copy the values from the passed matrix
void load(in sequence<float> array); // copy 16 floats into the matrix
sequence<float> getAsArray(); // return the matrix as an array of 16 floats
- CanvasFloatArray getAsCanvasFloatArray(); // return the matrix as a CanvasFloatArray with 16 values
+ WebGLFloatArray getAsWebGLFloatArray(); // return the matrix as a WebGLFloatArray with 16 values
void makeIdentity(); // replace the matrix with identity
void transpose(); // replace the matrix with its transpose
void invert(); // replace the matrix with its inverse
@@ -139,9 +139,9 @@ CanvasMatrix4.prototype.getAsArray = function()
];
}
-CanvasMatrix4.prototype.getAsCanvasFloatArray = function()
+CanvasMatrix4.prototype.getAsWebGLFloatArray = function()
{
- return new CanvasFloatArray(this.getAsArray());
+ return new WebGLFloatArray(this.getAsArray());
}
CanvasMatrix4.prototype.makeIdentity = function()
diff --git a/WebKitSite/blog-files/webgl/resources/utils3d.js b/WebKitSite/blog-files/webgl/resources/utils3d.js
index e8f43a8..f51ac84 100644
--- a/WebKitSite/blog-files/webgl/resources/utils3d.js
+++ b/WebKitSite/blog-files/webgl/resources/utils3d.js
@@ -1,3 +1,22 @@
+// The WebGL spec was recently updated to replace the Canvas prefix on types with the WebGL prefix.
+// For compatibility reasons we set up aliases to from the WebGL prefixed typename to the
+// Canvas prefixed name for the benefit of older builds of WebKit and Mozilla
+if (!("WebGLFloatArray" in window))
+ WebGLFloatArray = window.CanvasFloatArray;
+if (!("WebGLByteArray" in window))
+ WebGLByteArray = window.CanvasByteArray;
+if (!("WebGLIntArray" in window))
+ WebGLIntArray = window.CanvasIntArray;
+if (!("WebGLShortArray" in window))
+ WebGLShortArray = window.CanvasShortArray;
+if (!("WebGLUnsignedByteArray" in window))
+ WebGLUnsignedByteArray = window.CanvasUnsignedByteArray;
+if (!("WebGLUnsignedIntArray" in window))
+ WebGLUnsignedIntArray = window.CanvasUnsignedIntArray;
+if (!("WebGLUnsignedShortArray" in window))
+ WebGLUnsignedShortArray = window.CanvasUnsignedShortArray;
+
+
//
// initWebGL
//
@@ -149,7 +168,7 @@ function makeBox(ctx)
// v2------v3
//
// vertex coords array
- var vertices = new CanvasFloatArray(
+ var vertices = new WebGLFloatArray(
[ 1, 1, 1, -1, 1, 1, -1,-1, 1, 1,-1, 1, // v0-v1-v2-v3 front
1, 1, 1, 1,-1, 1, 1,-1,-1, 1, 1,-1, // v0-v3-v4-v5 right
1, 1, 1, 1, 1,-1, -1, 1,-1, -1, 1, 1, // v0-v5-v6-v1 top
@@ -159,7 +178,7 @@ function makeBox(ctx)
);
// normal array
- var normals = new CanvasFloatArray(
+ var normals = new WebGLFloatArray(
[ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, // v0-v1-v2-v3 front
1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, // v0-v3-v4-v5 right
0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, // v0-v5-v6-v1 top
@@ -170,7 +189,7 @@ function makeBox(ctx)
// texCoord array
- var texCoords = new CanvasFloatArray(
+ var texCoords = new WebGLFloatArray(
[ 1, 1, 0, 1, 0, 0, 1, 0, // v0-v1-v2-v3 front
0, 1, 0, 0, 1, 0, 1, 1, // v0-v3-v4-v5 right
1, 0, 1, 1, 0, 1, 0, 0, // v0-v5-v6-v1 top
@@ -180,7 +199,7 @@ function makeBox(ctx)
);
// index array
- var indices = new CanvasUnsignedByteArray(
+ var indices = new WebGLUnsignedByteArray(
[ 0, 1, 2, 0, 2, 3, // front
4, 5, 6, 4, 6, 7, // right
8, 9,10, 8,10,11, // top
@@ -280,20 +299,20 @@ function makeSphere(ctx, radius, lats, longs)
retval.normalObject = ctx.createBuffer();
ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, new CanvasFloatArray(normalData), ctx.STATIC_DRAW);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(normalData), ctx.STATIC_DRAW);
retval.texCoordObject = ctx.createBuffer();
ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, new CanvasFloatArray(texCoordData), ctx.STATIC_DRAW);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(texCoordData), ctx.STATIC_DRAW);
retval.vertexObject = ctx.createBuffer();
ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, new CanvasFloatArray(geometryData), ctx.STATIC_DRAW);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new WebGLFloatArray(geometryData), ctx.STATIC_DRAW);
retval.numIndices = indexData.length;
retval.indexObject = ctx.createBuffer();
ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, retval.indexObject);
- ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new CanvasUnsignedShortArray(indexData), ctx.STREAM_DRAW);
+ ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray(indexData), ctx.STREAM_DRAW);
return retval;
}
@@ -446,20 +465,20 @@ function doLoadObj(obj, text)
// set the VBOs
obj.normalObject = obj.ctx.createBuffer();
obj.ctx.bindBuffer(obj.ctx.ARRAY_BUFFER, obj.normalObject);
- obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new CanvasFloatArray(normalArray), obj.ctx.STATIC_DRAW);
+ obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new WebGLFloatArray(normalArray), obj.ctx.STATIC_DRAW);
obj.texCoordObject = obj.ctx.createBuffer();
obj.ctx.bindBuffer(obj.ctx.ARRAY_BUFFER, obj.texCoordObject);
- obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new CanvasFloatArray(textureArray), obj.ctx.STATIC_DRAW);
+ obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new WebGLFloatArray(textureArray), obj.ctx.STATIC_DRAW);
obj.vertexObject = obj.ctx.createBuffer();
obj.ctx.bindBuffer(obj.ctx.ARRAY_BUFFER, obj.vertexObject);
- obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new CanvasFloatArray(vertexArray), obj.ctx.STATIC_DRAW);
+ obj.ctx.bufferData(obj.ctx.ARRAY_BUFFER, new WebGLFloatArray(vertexArray), obj.ctx.STATIC_DRAW);
obj.numIndices = indexArray.length;
obj.indexObject = obj.ctx.createBuffer();
obj.ctx.bindBuffer(obj.ctx.ELEMENT_ARRAY_BUFFER, obj.indexObject);
- obj.ctx.bufferData(obj.ctx.ELEMENT_ARRAY_BUFFER, new CanvasUnsignedShortArray(indexArray), obj.ctx.STREAM_DRAW);
+ obj.ctx.bufferData(obj.ctx.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray(indexArray), obj.ctx.STREAM_DRAW);
obj.loaded = true;
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list