[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
kbr at google.com
kbr at google.com
Wed Dec 22 11:11:00 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 2451cfd19a4f3b99519f5e7a81c426c923bb3fbf
Author: kbr at google.com <kbr at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Jul 14 18:18:23 2010 +0000
2010-07-14 Kenneth Russell <kbr at google.com>
Reviewed by Darin Fisher.
Synchronize webgl-test.js from Khronos repository
https://bugs.webkit.org/show_bug.cgi?id=42212
Incorporated latest webgl-test.js from Khronos repository. Deleted
utils3d.js and removed references to it from tests. Updated those
tests which were using the create3DDebugContext helper function,
which has been removed. Rebaselined five tests.
* fast/canvas/webgl/context-attributes-expected.txt:
* fast/canvas/webgl/context-attributes.html:
* fast/canvas/webgl/index-validation-copies-indices-expected.txt:
* fast/canvas/webgl/index-validation-copies-indices.html:
* fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt:
* fast/canvas/webgl/index-validation-verifies-too-many-indices.html:
* fast/canvas/webgl/index-validation-with-resized-buffer.html:
* fast/canvas/webgl/null-object-behaviour-expected.txt:
* fast/canvas/webgl/null-object-behaviour.html:
* fast/canvas/webgl/resources/utils3d.js: Removed.
* fast/canvas/webgl/resources/webgl-test.js:
(assertMsg):
(webglTestLog):
(create3DContext):
(create3DContextWithWrapperThatThrowsOnGLError.wrap.getError):
(create3DContextWithWrapperThatThrowsOnGLError):
(getGLErrorAsString):
(shouldGenerateGLError):
(glErrorShouldBe):
(createProgram):
(initWebGL):
(getShaderSource):
(loadShader):
(loadShaderFromFile):
(loadShaderFromScript):
(loadProgram):
(loadStandardVertexShader):
(loadStandardFragmentShader):
(makeBox):
(makeSphere):
(loadObj.req.onreadystatechange):
(loadObj):
(processLoadObj):
(doLoadObj):
(loadImageTexture.texture.image.onload):
(loadImageTexture):
(doLoadImageTexture):
(Framerate.fr):
(Framerate):
(Framerate.prototype.updateFramerate):
(Framerate.prototype.snapshot):
* fast/canvas/webgl/texImage2DImageDataTest.html:
* fast/canvas/webgl/texture-active-bind.html:
* fast/canvas/webgl/texture-complete.html:
* fast/canvas/webgl/triangle.html:
* fast/canvas/webgl/uniform-location-expected.txt:
* fast/canvas/webgl/uniform-location.html:
* fast/canvas/webgl/viewport-unchanged-upon-resize.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@63333 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3f8f6da..ce65236 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,64 @@
+2010-07-14 Kenneth Russell <kbr at google.com>
+
+ Reviewed by Darin Fisher.
+
+ Synchronize webgl-test.js from Khronos repository
+ https://bugs.webkit.org/show_bug.cgi?id=42212
+
+ Incorporated latest webgl-test.js from Khronos repository. Deleted
+ utils3d.js and removed references to it from tests. Updated those
+ tests which were using the create3DDebugContext helper function,
+ which has been removed. Rebaselined five tests.
+
+ * fast/canvas/webgl/context-attributes-expected.txt:
+ * fast/canvas/webgl/context-attributes.html:
+ * fast/canvas/webgl/index-validation-copies-indices-expected.txt:
+ * fast/canvas/webgl/index-validation-copies-indices.html:
+ * fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt:
+ * fast/canvas/webgl/index-validation-verifies-too-many-indices.html:
+ * fast/canvas/webgl/index-validation-with-resized-buffer.html:
+ * fast/canvas/webgl/null-object-behaviour-expected.txt:
+ * fast/canvas/webgl/null-object-behaviour.html:
+ * fast/canvas/webgl/resources/utils3d.js: Removed.
+ * fast/canvas/webgl/resources/webgl-test.js:
+ (assertMsg):
+ (webglTestLog):
+ (create3DContext):
+ (create3DContextWithWrapperThatThrowsOnGLError.wrap.getError):
+ (create3DContextWithWrapperThatThrowsOnGLError):
+ (getGLErrorAsString):
+ (shouldGenerateGLError):
+ (glErrorShouldBe):
+ (createProgram):
+ (initWebGL):
+ (getShaderSource):
+ (loadShader):
+ (loadShaderFromFile):
+ (loadShaderFromScript):
+ (loadProgram):
+ (loadStandardVertexShader):
+ (loadStandardFragmentShader):
+ (makeBox):
+ (makeSphere):
+ (loadObj.req.onreadystatechange):
+ (loadObj):
+ (processLoadObj):
+ (doLoadObj):
+ (loadImageTexture.texture.image.onload):
+ (loadImageTexture):
+ (doLoadImageTexture):
+ (Framerate.fr):
+ (Framerate):
+ (Framerate.prototype.updateFramerate):
+ (Framerate.prototype.snapshot):
+ * fast/canvas/webgl/texImage2DImageDataTest.html:
+ * fast/canvas/webgl/texture-active-bind.html:
+ * fast/canvas/webgl/texture-complete.html:
+ * fast/canvas/webgl/triangle.html:
+ * fast/canvas/webgl/uniform-location-expected.txt:
+ * fast/canvas/webgl/uniform-location.html:
+ * fast/canvas/webgl/viewport-unchanged-upon-resize.html:
+
2010-07-14 Tony Gentilcore <tonyg at chromium.org>
Unreviewed, build fix for r63326.
diff --git a/LayoutTests/fast/canvas/webgl/context-attributes-expected.txt b/LayoutTests/fast/canvas/webgl/context-attributes-expected.txt
index b5d5eec..a1b1761 100644
--- a/LayoutTests/fast/canvas/webgl/context-attributes-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/context-attributes-expected.txt
@@ -3,7 +3,7 @@ Test passing down and fetching of WebGLContextAttributes
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Test default values
-PASS context = create3DContext() is non-null.
+PASS context = create3DContext(null) is non-null.
PASS attribs = context.getContextAttributes() is non-null.
PASS attribs.depth is true
PASS attribs.alpha is true
@@ -11,7 +11,7 @@ PASS attribs.stencil is false
PASS attribs.antialias == true || attribs.antialias == false is true
PASS attribs.premultipliedAlpha is true
Test customized values
-PASS context = create3DContext({ stencil: false, antialias: false }) is non-null.
+PASS context = create3DContext(null, { stencil: false, antialias: false }) is non-null.
PASS attribs = context.getContextAttributes() is non-null.
PASS attribs.depth is true
PASS attribs.alpha is true
@@ -19,14 +19,14 @@ PASS attribs.stencil is false
PASS attribs.antialias is false
PASS attribs.premultipliedAlpha is true
Test customized values
-PASS context = create3DContext({ depth: false, stencil: true, antialias: false }) is non-null.
+PASS context = create3DContext(null, { depth: false, stencil: true, antialias: false }) is non-null.
PASS attribs = context.getContextAttributes() is non-null.
PASS attribs.depth == attribs.stencil is true
PASS attribs.alpha is true
PASS attribs.antialias is false
PASS attribs.premultipliedAlpha is true
Test customized values
-PASS context = create3DContext({ premultipliedAlpha: false, antialias: false }) is non-null.
+PASS context = create3DContext(null, { premultipliedAlpha: false, antialias: false }) is non-null.
PASS attribs = context.getContextAttributes() is non-null.
PASS attribs.depth is true
PASS attribs.alpha is true
diff --git a/LayoutTests/fast/canvas/webgl/context-attributes.html b/LayoutTests/fast/canvas/webgl/context-attributes.html
index 70270c7..2e7917a 100644
--- a/LayoutTests/fast/canvas/webgl/context-attributes.html
+++ b/LayoutTests/fast/canvas/webgl/context-attributes.html
@@ -14,7 +14,7 @@ description("Test passing down and fetching of WebGLContextAttributes");
debug("Test default values");
var context;
var attribs;
-shouldBeNonNull("context = create3DContext()");
+shouldBeNonNull("context = create3DContext(null)");
shouldBeNonNull("attribs = context.getContextAttributes()");
shouldBe("attribs.depth", "true");
shouldBe("attribs.alpha", "true");
@@ -24,7 +24,7 @@ shouldBe("attribs.antialias == true || attribs.antialias == false", "true");
shouldBe("attribs.premultipliedAlpha", "true");
debug ("Test customized values");
-shouldBeNonNull("context = create3DContext({ stencil: false, antialias: false })");
+shouldBeNonNull("context = create3DContext(null, { stencil: false, antialias: false })");
shouldBeNonNull("attribs = context.getContextAttributes()");
shouldBe("attribs.depth", "true");
shouldBe("attribs.alpha", "true");
@@ -36,7 +36,7 @@ debug("Test customized values");
// (stencil == true && depth == false) is not supported.
// Default depth to true if EXT_packed_depth_stencil is supported.
// Otherwise, both depth and stencil should be false.
-shouldBeNonNull("context = create3DContext({ depth: false, stencil: true, antialias: false })");
+shouldBeNonNull("context = create3DContext(null, { depth: false, stencil: true, antialias: false })");
shouldBeNonNull("attribs = context.getContextAttributes()");
shouldBe("attribs.depth == attribs.stencil", "true");
shouldBe("attribs.alpha", "true");
@@ -45,7 +45,7 @@ shouldBe("attribs.premultipliedAlpha", "true");
debug("Test customized values");
// (premultipliedAlpha == false) is not supported, default to true
-shouldBeNonNull("context = create3DContext({ premultipliedAlpha: false, antialias: false })");
+shouldBeNonNull("context = create3DContext(null, { premultipliedAlpha: false, antialias: false })");
shouldBeNonNull("attribs = context.getContextAttributes()");
shouldBe("attribs.depth", "true");
shouldBe("attribs.alpha", "true");
diff --git a/LayoutTests/fast/canvas/webgl/index-validation-copies-indices-expected.txt b/LayoutTests/fast/canvas/webgl/index-validation-copies-indices-expected.txt
index f0c6d9a..2785f86 100644
--- a/LayoutTests/fast/canvas/webgl/index-validation-copies-indices-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/index-validation-copies-indices-expected.txt
@@ -4,13 +4,13 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
Regression test for https://bugs.webkit.org/show_bug.cgi?id=32748 : Index validation code must always copy client data
PASS context.checkFramebufferStatus(context.FRAMEBUFFER) is context.FRAMEBUFFER_COMPLETE
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) is undefined.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) threw exception GL error 1282 in drawElements.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) threw exception GL error 1282 in drawElements.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) generated expected GL error: NO_ERROR.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) generated expected GL error: INVALID_OPERATION.
PASS context.checkFramebufferStatus(context.FRAMEBUFFER) is context.FRAMEBUFFER_COMPLETE
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) is undefined.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) threw exception GL error 1282 in drawElements.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) threw exception GL error 1282 in drawElements.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) generated expected GL error: NO_ERROR.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) generated expected GL error: INVALID_OPERATION.
PASS successfullyParsed is true
diff --git a/LayoutTests/fast/canvas/webgl/index-validation-copies-indices.html b/LayoutTests/fast/canvas/webgl/index-validation-copies-indices.html
index faa9533..66b2c84 100644
--- a/LayoutTests/fast/canvas/webgl/index-validation-copies-indices.html
+++ b/LayoutTests/fast/canvas/webgl/index-validation-copies-indices.html
@@ -13,7 +13,7 @@ description('Test that client data is always copied during bufferData and buffer
debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32748">https://bugs.webkit.org/show_bug.cgi?id=32748</a> : <code>Index validation code must always copy client data</code>');
-var context = create3DDebugContext();
+var context = create3DContext();
var program = loadStandardProgram(context);
context.useProgram(program);
@@ -30,15 +30,15 @@ context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
var indices = new WebGLUnsignedShortArray([ 10000, 0, 1, 2, 3, 10000 ]);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
shouldBe('context.checkFramebufferStatus(context.FRAMEBUFFER)', 'context.FRAMEBUFFER_COMPLETE');
-shouldBeUndefined("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
indices[0] = 2;
indices[5] = 1;
shouldBe("context.checkFramebufferStatus(context.FRAMEBUFFER)", "context.FRAMEBUFFER_COMPLETE");
-shouldBeUndefined("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
successfullyParsed = true;
diff --git a/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt b/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt
index 87fe811..2c557ab 100644
--- a/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices-expected.txt
@@ -3,9 +3,9 @@ Regression test for https://bugs.webkit.org/show_bug.cgi?id=32692 : Index valida
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Test out of range indices
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) is undefined.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) threw exception GL error 1282 in drawElements.
-PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) threw exception GL error 1282 in drawElements.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2) generated expected GL error: NO_ERROR.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4) generated expected GL error: INVALID_OPERATION.
PASS successfullyParsed is true
diff --git a/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices.html b/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices.html
index 9b31abd..936c4c6 100644
--- a/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices.html
+++ b/LayoutTests/fast/canvas/webgl/index-validation-verifies-too-many-indices.html
@@ -11,7 +11,7 @@
<script>
description('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32692">https://bugs.webkit.org/show_bug.cgi?id=32692</a> : <code>Index validation for drawElements examines too many indices</code>');
-var context = create3DDebugContext();
+var context = create3DContext();
var program = loadStandardProgram(context);
context.useProgram(program);
@@ -27,9 +27,9 @@ var indexObject = context.createBuffer();
debug("Test out of range indices")
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new WebGLUnsignedShortArray([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
-shouldBeUndefined("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
-shouldThrow("context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
debug("")
successfullyParsed = true;
diff --git a/LayoutTests/fast/canvas/webgl/index-validation-with-resized-buffer.html b/LayoutTests/fast/canvas/webgl/index-validation-with-resized-buffer.html
index c9fceda..6f8fde9 100644
--- a/LayoutTests/fast/canvas/webgl/index-validation-with-resized-buffer.html
+++ b/LayoutTests/fast/canvas/webgl/index-validation-with-resized-buffer.html
@@ -3,7 +3,6 @@
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
-<script src="resources/utils3d.js"></script>
</head>
<body>
<canvas id="example" width="1px" height="1px"></canvas>
diff --git a/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt b/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
index ebeb004..725dad7 100644
--- a/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/null-object-behaviour-expected.txt
@@ -2,29 +2,29 @@ Tests calling WebGL APIs without providing the necessary objects
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS context.compileShader() threw exception GL error 1281 in compileShader.
-PASS context.linkProgram() threw exception GL error 1281 in linkProgram.
-PASS context.attachShader() threw exception GL error 1281 in attachShader.
-PASS context.attachShader(program, undefined) threw exception GL error 1281 in attachShader.
-PASS context.attachShader(undefined, shader) threw exception GL error 1281 in attachShader.
-PASS context.detachShader(program, undefined) threw exception GL error 1281 in detachShader.
-PASS context.detachShader(undefined, shader) threw exception GL error 1281 in detachShader.
-PASS context.shaderSource() threw exception GL error 1281 in shaderSource.
-PASS context.shaderSource(undefined, 'foo') threw exception GL error 1281 in shaderSource.
-PASS context.bindAttribLocation(undefined, 0, 'foo') threw exception GL error 1281 in bindAttribLocation.
-PASS context.bindBuffer(context.ARRAY_BUFFER, 0) is undefined.
-PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) is undefined.
-PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) is undefined.
-PASS context.bindTexture(context.TEXTURE_2D, 0) is undefined.
-PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) threw exception GL error 1282 in framebufferRenderbuffer.
-PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) threw exception GL error 1282 in framebufferTexture2D.
-PASS context.getProgramParameter(undefined, 0) threw exception GL error 1281 in getProgramParameter.
-PASS context.getProgramInfoLog(undefined, 0) threw exception GL error 1281 in getProgramInfoLog.
-PASS context.getShaderParameter(undefined, 0) threw exception GL error 1281 in getShaderParameter.
-PASS context.getShaderInfoLog(undefined, 0) threw exception GL error 1281 in getShaderInfoLog.
-PASS context.getShaderSource(undefined) threw exception GL error 1281 in getShaderSource.
-PASS context.getUniform(undefined, 0) threw exception GL error 1281 in getUniform.
-PASS context.getUniformLocation(undefined, 'foo') threw exception GL error 1281 in getUniformLocation.
+PASS context.compileShader() generated expected GL error: INVALID_VALUE.
+PASS context.linkProgram() generated expected GL error: INVALID_VALUE.
+PASS context.attachShader() generated expected GL error: INVALID_VALUE.
+PASS context.attachShader(program, undefined) generated expected GL error: INVALID_VALUE.
+PASS context.attachShader(undefined, shader) generated expected GL error: INVALID_VALUE.
+PASS context.detachShader(program, undefined) generated expected GL error: INVALID_VALUE.
+PASS context.detachShader(undefined, shader) generated expected GL error: INVALID_VALUE.
+PASS context.shaderSource() generated expected GL error: INVALID_VALUE.
+PASS context.shaderSource(undefined, 'foo') generated expected GL error: INVALID_VALUE.
+PASS context.bindAttribLocation(undefined, 0, 'foo') generated expected GL error: INVALID_VALUE.
+PASS context.bindBuffer(context.ARRAY_BUFFER, 0) generated expected GL error: NO_ERROR.
+PASS context.bindFramebuffer(context.FRAMEBUFFER, 0) generated expected GL error: NO_ERROR.
+PASS context.bindRenderbuffer(context.RENDERBUFFER, 0) generated expected GL error: NO_ERROR.
+PASS context.bindTexture(context.TEXTURE_2D, 0) generated expected GL error: NO_ERROR.
+PASS context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0) generated expected GL error: INVALID_OPERATION.
+PASS context.getProgramParameter(undefined, 0) generated expected GL error: INVALID_VALUE.
+PASS context.getProgramInfoLog(undefined, 0) generated expected GL error: INVALID_VALUE.
+PASS context.getShaderParameter(undefined, 0) generated expected GL error: INVALID_VALUE.
+PASS context.getShaderInfoLog(undefined, 0) generated expected GL error: INVALID_VALUE.
+PASS context.getShaderSource(undefined) generated expected GL error: INVALID_VALUE.
+PASS context.getUniform(undefined, 0) generated expected GL error: INVALID_VALUE.
+PASS context.getUniformLocation(undefined, 'foo') generated expected GL error: INVALID_VALUE.
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/LayoutTests/fast/canvas/webgl/null-object-behaviour.html b/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
index ca21d6e..0c6d9fa 100644
--- a/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
+++ b/LayoutTests/fast/canvas/webgl/null-object-behaviour.html
@@ -11,37 +11,33 @@
<script>
description("Tests calling WebGL APIs without providing the necessary objects");
-var context = create3DDebugContext();
+var context = create3DContext();
var program = loadStandardProgram(context);
var shader = loadStandardVertexShader(context);
-shouldThrow("context.compileShader()");
-shouldThrow("context.linkProgram()");
-shouldThrow("context.attachShader()");
-shouldThrow("context.attachShader(program, undefined)");
-shouldThrow("context.attachShader(undefined, shader)");
-shouldThrow("context.detachShader(program, undefined)");
-shouldThrow("context.detachShader(undefined, shader)");
-shouldThrow("context.shaderSource()");
-shouldThrow("context.shaderSource(undefined, 'foo')");
-shouldThrow("context.bindAttribLocation(undefined, 0, 'foo')");
-shouldBeUndefined("context.bindBuffer(context.ARRAY_BUFFER, 0)");
-shouldBeUndefined("context.bindFramebuffer(context.FRAMEBUFFER, 0)");
-shouldBeUndefined("context.bindRenderbuffer(context.RENDERBUFFER, 0)");
-shouldBeUndefined("context.bindTexture(context.TEXTURE_2D, 0)");
-// The following two throw exceptions because conceptually no
-// framebuffer is bound at this point. In reality the WebGL
-// implementation's internal framebuffer is bound, but we can't allow
-// user code to manipulate it.
-shouldThrow("context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
-shouldThrow("context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
-shouldThrow("context.getProgramParameter(undefined, 0)");
-shouldThrow("context.getProgramInfoLog(undefined, 0)");
-shouldThrow("context.getShaderParameter(undefined, 0)");
-shouldThrow("context.getShaderInfoLog(undefined, 0)");
-shouldThrow("context.getShaderSource(undefined)");
-shouldThrow("context.getUniform(undefined, 0)");
-shouldThrow("context.getUniformLocation(undefined, 'foo')");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.compileShader()");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.linkProgram()");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader()");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(program, undefined)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.attachShader(undefined, shader)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(program, undefined)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.detachShader(undefined, shader)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource()");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.shaderSource(undefined, 'foo')");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.bindAttribLocation(undefined, 0, 'foo')");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, 0)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindFramebuffer(context.FRAMEBUFFER, 0)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, 0)");
+shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, 0)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferRenderbuffer(context.FRAMEBUFFER, context.DEPTH_ATTACHMENT, context.RENDERBUFFER, 0)");
+shouldGenerateGLError(context, context.INVALID_OPERATION, "context.framebufferTexture2D(context.FRAMEBUFFER, context.COLOR_ATTACHMENT0, context.TEXTURE_2D, 0, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramParameter(undefined, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getProgramInfoLog(undefined, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderParameter(undefined, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderInfoLog(undefined, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getShaderSource(undefined)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniform(undefined, 0)");
+shouldGenerateGLError(context, context.INVALID_VALUE, "context.getUniformLocation(undefined, 'foo')");
successfullyParsed = true;
</script>
diff --git a/LayoutTests/fast/canvas/webgl/resources/utils3d.js b/LayoutTests/fast/canvas/webgl/resources/utils3d.js
deleted file mode 100644
index 7bb365c..0000000
--- a/LayoutTests/fast/canvas/webgl/resources/utils3d.js
+++ /dev/null
@@ -1,540 +0,0 @@
-//
-// initWebGL
-//
-// Initialize the Canvas element with the passed name as a WebGL object and return the
-// WebGLRenderingContext.
-//
-// Load shaders with the passed names and create a program with them. Return this program
-// in the 'program' property of the returned context.
-//
-// For each string in the passed attribs array, bind an attrib with that name at that index.
-// Once the attribs are bound, link the program and then use it.
-//
-// Set the clear color to the passed array (4 values) and set the clear depth to the passed value.
-// Enable depth testing and blending with a blend func of (SRC_ALPHA, ONE_MINUS_SRC_ALPHA)
-//
-// A console function is added to the context: console(string). This can be replaced
-// by the caller. By default, it maps to the window.console() function on WebKit and to
-// an empty function on other browsers.
-//
-function initWebGL(canvasName, vshader, fshader, attribs, clearColor, clearDepth, contextAttribs)
-{
- var canvas = document.getElementById(canvasName);
- var gl = canvas.getContext("experimental-webgl", contextAttribs);
- if (!gl) {
- alert("No WebGL context found");
- return null;
- }
-
- // Add a console
- gl.console = ("console" in window) ? window.console : { log: function() { } };
-
- // create our shaders
- var vertexShader = loadShader(gl, vshader);
- var fragmentShader = loadShader(gl, fshader);
-
- if (!vertexShader || !fragmentShader)
- return null;
-
- // Create the program object
- gl.program = gl.createProgram();
-
- if (!gl.program)
- return null;
-
- // Attach our two shaders to the program
- gl.attachShader (gl.program, vertexShader);
- gl.attachShader (gl.program, fragmentShader);
-
- // Bind attributes
- for (var i in attribs)
- gl.bindAttribLocation (gl.program, i, attribs[i]);
-
- // Link the program
- gl.linkProgram(gl.program);
-
- // Check the link status
- var linked = gl.getProgramParameter(gl.program, gl.LINK_STATUS);
- if (!linked) {
- // something went wrong with the link
- var error = gl.getProgramInfoLog (gl.program);
- gl.console.log("Error in program linking:"+error);
-
- gl.deleteProgram(gl.program);
- gl.deleteProgram(fragmentShader);
- gl.deleteProgram(vertexShader);
-
- return null;
- }
-
- gl.useProgram(gl.program);
-
- gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- gl.clearDepth(clearDepth);
-
- gl.enable(gl.DEPTH_TEST);
- gl.enable(gl.BLEND);
- gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
-
- return gl;
-}
-
-//
-// loadShader
-//
-// 'shaderId' is the id of a <script> element containing the shader source string.
-// Load this shader and return the WebGLShader object corresponding to it.
-//
-function loadShader(ctx, shaderId)
-{
- var shaderScript = document.getElementById(shaderId);
- if (!shaderScript) {
- ctx.console.log("*** Error: shader script '"+shaderId+"' not found");
- return null;
- }
-
- if (shaderScript.type == "x-shader/x-vertex")
- var shaderType = ctx.VERTEX_SHADER;
- else if (shaderScript.type == "x-shader/x-fragment")
- var shaderType = ctx.FRAGMENT_SHADER;
- else {
- ctx.console.log("*** Error: shader script '"+shaderId+"' of undefined type '"+shaderScript.type+"'");
- return null;
- }
-
- // Create the shader object
- var shader = ctx.createShader(shaderType);
- if (shader == null) {
- ctx.console.log("*** Error: unable to create shader '"+shaderId+"'");
- return null;
- }
-
- // Load the shader source
- ctx.shaderSource(shader, shaderScript.text);
-
- // Compile the shader
- ctx.compileShader(shader);
-
- // Check the compile status
- var compiled = ctx.getShaderParameter(shader, ctx.COMPILE_STATUS);
- if (!compiled) {
- // Something went wrong during compilation; get the error
- var error = ctx.getShaderInfoLog(shader);
- ctx.console.log("*** Error compiling shader '"+shaderId+"':"+error);
- ctx.deleteShader(shader);
- return null;
- }
-
- return shader;
-}
-
-//
-// makeBox
-//
-// Create a box with vertices, normals and texCoords. Create VBOs for each as well as the index array.
-// Return an object with the following properties:
-//
-// normalObject WebGLBuffer object for normals
-// texCoordObject WebGLBuffer object for texCoords
-// vertexObject WebGLBuffer object for vertices
-// indexObject WebGLBuffer object for indices
-// numIndices The number of indices in the indexObject
-//
-function makeBox(ctx)
-{
- // box
- // v6----- v5
- // /| /|
- // v1------v0|
- // | | | |
- // | |v7---|-|v4
- // |/ |/
- // v2------v3
- //
- // vertex coords array
- 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
- -1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, // v1-v6-v7-v2 left
- -1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, // v7-v4-v3-v2 bottom
- 1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 ] // v4-v7-v6-v5 back
- );
-
- // normal array
- 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
- -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // v1-v6-v7-v2 left
- 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, // v7-v4-v3-v2 bottom
- 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1 ] // v4-v7-v6-v5 back
- );
-
-
- // texCoord array
- 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
- 1, 1, 0, 1, 0, 0, 1, 0, // v1-v6-v7-v2 left
- 0, 0, 1, 0, 1, 1, 0, 1, // v7-v4-v3-v2 bottom
- 0, 0, 1, 0, 1, 1, 0, 1 ] // v4-v7-v6-v5 back
- );
-
- // index array
- 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
- 12,13,14, 12,14,15, // left
- 16,17,18, 16,18,19, // bottom
- 20,21,22, 20,22,23 ] // back
- );
-
- var retval = { };
-
- retval.normalObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, normals, ctx.STATIC_DRAW);
-
- retval.texCoordObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, texCoords, ctx.STATIC_DRAW);
-
- retval.vertexObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
- ctx.bufferData(ctx.ARRAY_BUFFER, vertices, ctx.STATIC_DRAW);
-
- ctx.bindBuffer(ctx.ARRAY_BUFFER, null);
-
- retval.indexObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, retval.indexObject);
- ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, indices, ctx.STATIC_DRAW);
- ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, null);
-
- retval.numIndices = indices.length;
-
- return retval;
-}
-
-//
-// makeSphere
-//
-// Create a sphere with the passed number of latitude and longitude bands and the passed radius.
-// Sphere has vertices, normals and texCoords. Create VBOs for each as well as the index array.
-// Return an object with the following properties:
-//
-// normalObject WebGLBuffer object for normals
-// texCoordObject WebGLBuffer object for texCoords
-// vertexObject WebGLBuffer object for vertices
-// indexObject WebGLBuffer object for indices
-// numIndices The number of indices in the indexObject
-//
-function makeSphere(ctx, radius, lats, longs)
-{
- var geometryData = [ ];
- var normalData = [ ];
- var texCoordData = [ ];
- var indexData = [ ];
-
- for (var latNumber = 0; latNumber <= lats; ++latNumber) {
- for (var longNumber = 0; longNumber <= longs; ++longNumber) {
- var theta = latNumber * Math.PI / lats;
- var phi = longNumber * 2 * Math.PI / longs;
- var sinTheta = Math.sin(theta);
- var sinPhi = Math.sin(phi);
- var cosTheta = Math.cos(theta);
- var cosPhi = Math.cos(phi);
-
- var x = cosPhi * sinTheta;
- var y = cosTheta;
- var z = sinPhi * sinTheta;
- var u = 1-(longNumber/longs);
- var v = latNumber/lats;
-
- normalData.push(x);
- normalData.push(y);
- normalData.push(z);
- texCoordData.push(u);
- texCoordData.push(v);
- geometryData.push(radius * x);
- geometryData.push(radius * y);
- geometryData.push(radius * z);
- }
- }
-
- for (var latNumber = 0; latNumber < lats; ++latNumber) {
- for (var longNumber = 0; longNumber < longs; ++longNumber) {
- var first = (latNumber * (longs+1)) + longNumber;
- var second = first + longs + 1;
- indexData.push(first);
- indexData.push(second);
- indexData.push(first+1);
-
- indexData.push(second);
- indexData.push(second+1);
- indexData.push(first+1);
- }
- }
-
- var retval = { };
-
- retval.normalObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
- 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 WebGLFloatArray(texCoordData), ctx.STATIC_DRAW);
-
- retval.vertexObject = ctx.createBuffer();
- ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
- 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 WebGLUnsignedShortArray(indexData), ctx.STREAM_DRAW);
-
- return retval;
-}
-
-//
-// loadObj
-//
-// Load a .obj file from the passed URL. Return an object with a 'loaded' property set to false.
-// When the object load is complete, the 'loaded' property becomes true and the following
-// properties are set:
-//
-// normalObject WebGLBuffer object for normals
-// texCoordObject WebGLBuffer object for texCoords
-// vertexObject WebGLBuffer object for vertices
-// indexObject WebGLBuffer object for indices
-// numIndices The number of indices in the indexObject
-//
-function loadObj(ctx, url)
-{
- var obj = { loaded : false };
- obj.ctx = ctx;
- var req = new XMLHttpRequest();
- req.obj = obj;
- req.onreadystatechange = function () { processLoadObj(req) };
- req.open("GET", url, true);
- req.send(null);
- return obj;
-}
-
-function processLoadObj(req)
-{
- req.obj.ctx.console.log("req="+req)
- // only if req shows "complete"
- if (req.readyState == 4) {
- doLoadObj(req.obj, req.responseText);
- }
-}
-
-function doLoadObj(obj, text)
-{
- vertexArray = [ ];
- normalArray = [ ];
- textureArray = [ ];
- indexArray = [ ];
-
- var vertex = [ ];
- var normal = [ ];
- var texture = [ ];
- var facemap = { };
- var index = 0;
-
- var lines = text.split("\n");
- for (var lineIndex in lines) {
- var line = lines[lineIndex].replace(/[ \t]+/g, " ").replace(/\s\s*$/, "");
-
- // ignore comments
- if (line[0] == "#")
- continue;
-
- var array = line.split(" ");
- if (array[0] == "v") {
- // vertex
- vertex.push(parseFloat(array[1]));
- vertex.push(parseFloat(array[2]));
- vertex.push(parseFloat(array[3]));
- }
- else if (array[0] == "vt") {
- // normal
- texture.push(parseFloat(array[1]));
- texture.push(parseFloat(array[2]));
- }
- else if (array[0] == "vn") {
- // normal
- normal.push(parseFloat(array[1]));
- normal.push(parseFloat(array[2]));
- normal.push(parseFloat(array[3]));
- }
- else if (array[0] == "f") {
- // face
- if (array.length != 4) {
- obj.ctx.console.log("*** Error: face '"+line+"' not handled");
- continue;
- }
-
- for (var i = 1; i < 4; ++i) {
- if (!(array[i] in facemap)) {
- // add a new entry to the map and arrays
- var f = array[i].split("/");
- var vtx, nor, tex;
-
- if (f.length == 1) {
- vtx = parseInt(f[0]) - 1;
- nor = vtx;
- tex = vtx;
- }
- else if (f.length = 3) {
- vtx = parseInt(f[0]) - 1;
- tex = parseInt(f[1]) - 1;
- nor = parseInt(f[2]) - 1;
- }
- else {
- obj.ctx.console.log("*** Error: did not understand face '"+array[i]+"'");
- return null;
- }
-
- // do the vertices
- var x = 0;
- var y = 0;
- var z = 0;
- if (vtx * 3 + 2 < vertex.length) {
- x = vertex[vtx*3];
- y = vertex[vtx*3+1];
- z = vertex[vtx*3+2];
- }
- vertexArray.push(x);
- vertexArray.push(y);
- vertexArray.push(z);
-
- // do the textures
- x = 0;
- y = 0;
- if (tex * 2 + 1 < texture.length) {
- x = texture[tex*2];
- y = texture[tex*2+1];
- }
- textureArray.push(x);
- textureArray.push(y);
-
- // do the normals
- x = 0;
- y = 0;
- z = 1;
- if (nor * 3 + 2 < normal.length) {
- x = normal[nor*3];
- y = normal[nor*3+1];
- z = normal[nor*3+2];
- }
- normalArray.push(x);
- normalArray.push(y);
- normalArray.push(z);
-
- facemap[array[i]] = index++;
- }
-
- indexArray.push(facemap[array[i]]);
- }
- }
- }
-
- // 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 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 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 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 WebGLUnsignedShortArray(indexArray), obj.ctx.STREAM_DRAW);
-
- obj.loaded = true;
-}
-
-//
-// loadImageTexture
-//
-// Load the image at the passed url, place it in a new WebGLTexture object and return the WebGLTexture.
-//
-function loadImageTexture(ctx, url)
-{
- var texture = ctx.createTexture();
- texture.image = new Image();
- texture.image.onload = function() { doLoadImageTexture(ctx, texture.image, texture) }
- texture.image.src = url;
- return texture;
-}
-
-function doLoadImageTexture(ctx, image, texture)
-{
- ctx.enable(ctx.TEXTURE_2D);
- ctx.bindTexture(ctx.TEXTURE_2D, texture);
- ctx.texImage2D(ctx.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
- ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.LINEAR);
- ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.LINEAR_MIPMAP_LINEAR);
- ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE);
- ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE);
- ctx.generateMipmap(ctx.TEXTURE_2D)
- ctx.bindTexture(ctx.TEXTURE_2D, null);
-}
-
-//
-// Framerate object
-//
-// This object keeps track of framerate and displays it as the innerHTML text of the
-// HTML element with the passed id. Once created you call snapshot at the end
-// of every rendering cycle. Every 500ms the framerate is updated in the HTML element.
-//
-Framerate = function(id)
-{
- this.numFramerates = 10;
- this.framerateUpdateInterval = 500;
- this.id = id;
-
- this.renderTime = -1;
- this.framerates = [ ];
- self = this;
- var fr = function() { self.updateFramerate() }
- setInterval(fr, this.framerateUpdateInterval);
-}
-
-Framerate.prototype.updateFramerate = function()
-{
- var tot = 0;
- for (var i = 0; i < this.framerates.length; ++i)
- tot += this.framerates[i];
-
- var framerate = tot / this.framerates.length;
- framerate = Math.round(framerate);
- document.getElementById(this.id).innerHTML = "Framerate:"+framerate+"fps";
-}
-
-Framerate.prototype.snapshot = function()
-{
- if (this.renderTime < 0)
- this.renderTime = new Date().getTime();
- else {
- var newTime = new Date().getTime();
- var t = newTime - this.renderTime;
- var framerate = 1000/t;
- this.framerates.push(framerate);
- while (this.framerates.length > this.numFramerates)
- this.framerates.shift();
- this.renderTime = newTime;
- }
-}
diff --git a/LayoutTests/fast/canvas/webgl/resources/webgl-test.js b/LayoutTests/fast/canvas/webgl/resources/webgl-test.js
index dca98be..2221f1a 100644
--- a/LayoutTests/fast/canvas/webgl/resources/webgl-test.js
+++ b/LayoutTests/fast/canvas/webgl/resources/webgl-test.js
@@ -1,19 +1,56 @@
+//----------------------------------------------------------------------
+// Differences with respect to Khronos version of webgl-test.js
if (window.layoutTestController)
layoutTestController.overridePreference("WebKitWebGLEnabled", "1");
-function getShaderSource(file) {
- var xhr = new XMLHttpRequest();
- xhr.open("GET", file, false);
- xhr.send();
- return xhr.responseText;
+function assertMsg(assertion, msg) {
+ if (assertion) {
+ testPassed(msg);
+ } else {
+ testFailed(msg);
+ }
}
-function create3DContext(attrs) {
- var canvas = document.createElement("canvas");
+//
+//----------------------------------------------------------------------
+
+function webglTestLog(msg) {
+ if (window.console && window.console.log) {
+ window.console.log(msg);
+ }
+ if (document.getElementById("console")) {
+ var log = document.getElementById("console");
+ log.innerHTML += msg + "<br>";
+ }
+}
+
+//
+// create3DContext
+//
+// Returns the WebGLRenderingContext for any known implementation.
+//
+function create3DContext(canvas, attributes)
+{
+ if (!canvas)
+ canvas = document.createElement("canvas");
+ var context = null;
try {
- return canvas.getContext("experimental-webgl", attrs);
+ context = canvas.getContext("experimental-webgl", attributes);
} catch(e) {}
- return canvas.getContext("moz-webgl", attrs);
+ if (!context) {
+ try {
+ context = canvas.getContext("webkit-3d", attributes);
+ } catch(e) {}
+ }
+ if (!context) {
+ try {
+ context = canvas.getContext("moz-webgl", attributes);
+ } catch(e) {}
+ }
+ if (!context) {
+ throw "Unable to fetch WebGL rendering context for Canvas";
+ }
+ return context;
}
function createGLErrorWrapper(context, fname) {
@@ -26,25 +63,257 @@ function createGLErrorWrapper(context, fname) {
};
}
-function create3DDebugContext(attrs) {
- var context = create3DContext(attrs);
- // Thanks to Ilmari Heikkinen for the idea on how to implement this so elegantly.
- var wrap = {};
- for (var i in context) {
- try {
- if (typeof context[i] == 'function') {
- wrap[i] = createGLErrorWrapper(context, i);
- } else {
- wrap[i] = context[i];
+function create3DContextWithWrapperThatThrowsOnGLError(canvas, attributes) {
+ var context = create3DContext(canvas, attributes);
+ // Thanks to Ilmari Heikkinen for the idea on how to implement this so elegantly.
+ var wrap = {};
+ for (var i in context) {
+ try {
+ if (typeof context[i] == 'function') {
+ wrap[i] = createGLErrorWrapper(context, i);
+ } else {
+ wrap[i] = context[i];
+ }
+ } catch (e) {
+ webglTestLog("createContextWrapperThatThrowsOnGLError: Error accessing " + i);
+ }
+ }
+ wrap.getError = function() {
+ return context.getError();
+ };
+ return wrap;
+}
+
+function getGLErrorAsString(ctx, err) {
+ if (err === ctx.NO_ERROR) {
+ return "NO_ERROR";
+ }
+ for (var name in ctx) {
+ if (ctx[name] === err) {
+ return name;
+ }
+ }
+ return err.toString();
+}
+
+function shouldGenerateGLError(ctx, glError, evalStr) {
+ var exception;
+ try {
+ eval(evalStr);
+ } catch (e) {
+ exception = e;
+ }
+ if (exception) {
+ testFailed(evalStr + " threw exception " + exception);
+ } else {
+ var err = ctx.getError();
+ if (err != glError) {
+ testFailed(evalStr + " expected: " + getGLErrorAsString(ctx, glError) + ". Was " + getGLErrorAsString(ctx, err) + ".");
+ } else {
+ testPassed(evalStr + " generated expected GL error: " + getGLErrorAsString(ctx, glError) + ".");
+ }
+ }
+}
+
+/**
+ * Tests that the first error GL returns is the specified error.
+ * @param {!WebGLContext} gl The WebGLContext to use.
+ * @param {number} glError The expected gl error.
+ * @param {string} opt_msg Optional additional message.
+ */
+function glErrorShouldBe(gl, glError, opt_msg) {
+ opt_msg = opt_msg || "";
+ var err = gl.getError();
+ if (err != glError) {
+ testFailed("getError expected: " + getGLErrorAsString(gl, glError) +
+ ". Was " + getGLErrorAsString(gl, err) + " : " + opt_msg);
+ } else {
+ testPassed("getError was expected value: " +
+ getGLErrorAsString(gl, glError) + " : " + opt_msg);
+ }
+};
+
+//
+// createProgram
+//
+// Create and return a program object, attaching each of the given shaders.
+//
+// If attribs are given, bind an attrib with that name at that index.
+//
+function createProgram(gl, vshaders, fshaders, attribs)
+{
+ if (typeof(vshaders) == "string")
+ vshaders = [vshaders];
+ if (typeof(fshaders) == "string")
+ fshaders = [fshaders];
+
+ var shaders = [];
+ var i;
+
+ for (i = 0; i < vshaders.length; ++i) {
+ var shader = loadShader(gl, vshaders[i], gl.VERTEX_SHADER);
+ if (!shader)
+ return null;
+ shaders.push(shader);
+ }
+
+ for (i = 0; i < fshaders.length; ++i) {
+ var shader = loadShader(gl, fshaders[i], gl.FRAGMENT_SHADER);
+ if (!shader)
+ return null;
+ shaders.push(shader);
+ }
+
+ var prog = gl.createProgram();
+ for (i = 0; i < shaders.length; ++i) {
+ gl.attachShader(prog, shaders[i]);
+ }
+
+ if (attribs) {
+ for (var i in attribs) {
+ gl.bindAttribLocation (prog, i, attribs[i]);
+ }
+ }
+
+ gl.linkProgram(prog);
+
+ // Check the link status
+ var linked = gl.getProgramParameter(prog, gl.LINK_STATUS);
+ if (!linked) {
+ // something went wrong with the link
+ var error = gl.getProgramInfoLog(prog);
+ webglTestLog("Error in program linking:" + error);
+
+ gl.deleteProgram(prog);
+ for (i = 0; i < shaders.length; ++i)
+ gl.deleteShader(shaders[i]);
+ return null;
+ }
+
+ return prog;
+}
+
+//
+// initWebGL
+//
+// Initialize the Canvas element with the passed name as a WebGL object and return the
+// WebGLRenderingContext.
+//
+// Load shaders with the passed names and create a program with them. Return this program
+// in the 'program' property of the returned context.
+//
+// For each string in the passed attribs array, bind an attrib with that name at that index.
+// Once the attribs are bound, link the program and then use it.
+//
+// Set the clear color to the passed array (4 values) and set the clear depth to the passed value.
+// Enable depth testing and blending with a blend func of (SRC_ALPHA, ONE_MINUS_SRC_ALPHA)
+//
+function initWebGL(canvasName, vshader, fshader, attribs, clearColor, clearDepth, contextAttribs)
+{
+ var canvas = document.getElementById(canvasName);
+ var gl = create3DContext(canvas, contextAttribs);
+ if (!gl) {
+ alert("No WebGL context found");
+ return null;
+ }
+
+ // Create the program object
+ gl.program = createProgram(gl, vshader, fshader, attribs);
+ if (!gl.program)
+ return null;
+
+ gl.useProgram(gl.program);
+
+ gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
+ gl.clearDepth(clearDepth);
+
+ gl.enable(gl.DEPTH_TEST);
+ gl.enable(gl.BLEND);
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
+
+ return gl;
+}
+
+//
+// getShaderSource
+//
+// Load the source from the passed shader file.
+//
+function getShaderSource(file)
+{
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", file, false);
+ xhr.send();
+ return xhr.responseText;
+}
+
+
+//
+// loadShader
+//
+// 'shader' is either the id of a <script> element containing the shader source
+// string, the shader string itself, or the URL of a file containing the shader
+// source. Load this shader and return the WebGLShader object corresponding to
+// it.
+//
+function loadShader(ctx, shaderId, shaderType, isFile)
+{
+ var shaderSource = "";
+
+ if (isFile)
+ shaderSource = getShaderSource(shaderId);
+ else {
+ var shaderScript = document.getElementById(shaderId);
+ if (!shaderScript) {
+ shaderSource = shaderId;
+ } else {
+ if (shaderScript.type == "x-shader/x-vertex") {
+ shaderType = ctx.VERTEX_SHADER;
+ } else if (shaderScript.type == "x-shader/x-fragment") {
+ shaderType = ctx.FRAGMENT_SHADER;
+ } else if (shaderType != ctx.VERTEX_SHADER && shaderType != ctx.FRAGMENT_SHADER) {
+ webglTestLog("*** Error: unknown shader type");
+ return null;
}
- } catch (e) {
- // console.log("create3DDebugContext: Error accessing " + i);
+
+ shaderSource = shaderScript.text;
}
}
- wrap.getError = function() {
- return context.getError();
- };
- return wrap;
+
+ // Create the shader object
+ var shader = ctx.createShader(shaderType);
+ if (shader == null) {
+ webglTestLog("*** Error: unable to create shader '"+shaderId+"'");
+ return null;
+ }
+
+ // Load the shader source
+ ctx.shaderSource(shader, shaderSource);
+
+ // Compile the shader
+ ctx.compileShader(shader);
+
+ // Check the compile status
+ var compiled = ctx.getShaderParameter(shader, ctx.COMPILE_STATUS);
+ if (!compiled) {
+ // Something went wrong during compilation; get the error
+ var error = ctx.getShaderInfoLog(shader);
+ webglTestLog("*** Error compiling shader '"+shader+"':"+error);
+ ctx.deleteShader(shader);
+ return null;
+ }
+
+ return shader;
+}
+
+function loadShaderFromFile(ctx, file, type)
+{
+ return loadShader(ctx, file, type, true);
+}
+
+function loadShaderFromScript(ctx, script)
+{
+ return loadShader(ctx, script, 0, false);
}
function loadStandardProgram(context) {
@@ -55,86 +324,431 @@ function loadStandardProgram(context) {
return program;
}
-function loadProgram(context, vertexShaderPath, fragmentShaderPath) {
+function loadProgram(context, vertexShaderPath, fragmentShaderPath, isFile) {
+ isFile = (isFile === undefined) ? true : isFile;
var program = context.createProgram();
- context.attachShader(program, loadVertexShader(context, vertexShaderPath));
- context.attachShader(program, loadFragmentShader(context, fragmentShaderPath));
+ context.attachShader(program, loadShader(context, vertexShaderPath, context.VERTEX_SHADER, isFile));
+ context.attachShader(program, loadShader(context, fragmentShaderPath, context.FRAGMENT_SHADER, isFile));
context.linkProgram(program);
return program;
}
function loadStandardVertexShader(context) {
- return loadVertexShader(context, "resources/vertexShader.vert");
-}
-
-function loadVertexShader(context, path) {
- var vertexShader = context.createShader(context.VERTEX_SHADER);
- context.shaderSource(vertexShader, getShaderSource(path));
- context.compileShader(vertexShader);
- return vertexShader;
+ return loadShader(context, "resources/vertexShader.vert", context.VERTEX_SHADER, true);
}
function loadStandardFragmentShader(context) {
- return loadFragmentShader(context, "resources/fragmentShader.frag");
+ return loadShader(context, "resources/fragmentShader.frag", context.FRAGMENT_SHADER, true);
}
-function loadFragmentShader(context, path) {
- var fragmentShader = context.createShader(context.FRAGMENT_SHADER);
- context.shaderSource(fragmentShader, getShaderSource(path));
- context.compileShader(fragmentShader);
- return fragmentShader;
+//
+// makeBox
+//
+// Create a box with vertices, normals and texCoords. Create VBOs for each as well as the index array.
+// Return an object with the following properties:
+//
+// normalObject WebGLBuffer object for normals
+// texCoordObject WebGLBuffer object for texCoords
+// vertexObject WebGLBuffer object for vertices
+// indexObject WebGLBuffer object for indices
+// numIndices The number of indices in the indexObject
+//
+function makeBox(ctx)
+{
+ // box
+ // v6----- v5
+ // /| /|
+ // v1------v0|
+ // | | | |
+ // | |v7---|-|v4
+ // |/ |/
+ // v2------v3
+ //
+ // vertex coords array
+ var vertices = new Float32Array(
+ [ 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
+ -1, 1, 1, -1, 1,-1, -1,-1,-1, -1,-1, 1, // v1-v6-v7-v2 left
+ -1,-1,-1, 1,-1,-1, 1,-1, 1, -1,-1, 1, // v7-v4-v3-v2 bottom
+ 1,-1,-1, -1,-1,-1, -1, 1,-1, 1, 1,-1 ] // v4-v7-v6-v5 back
+ );
+
+ // normal array
+ var normals = new Float32Array(
+ [ 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
+ -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, // v1-v6-v7-v2 left
+ 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, // v7-v4-v3-v2 bottom
+ 0, 0,-1, 0, 0,-1, 0, 0,-1, 0, 0,-1 ] // v4-v7-v6-v5 back
+ );
+
+
+ // texCoord array
+ var texCoords = new Float32Array(
+ [ 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
+ 1, 1, 0, 1, 0, 0, 1, 0, // v1-v6-v7-v2 left
+ 0, 0, 1, 0, 1, 1, 0, 1, // v7-v4-v3-v2 bottom
+ 0, 0, 1, 0, 1, 1, 0, 1 ] // v4-v7-v6-v5 back
+ );
+
+ // index array
+ var indices = new Uint8Array(
+ [ 0, 1, 2, 0, 2, 3, // front
+ 4, 5, 6, 4, 6, 7, // right
+ 8, 9,10, 8,10,11, // top
+ 12,13,14, 12,14,15, // left
+ 16,17,18, 16,18,19, // bottom
+ 20,21,22, 20,22,23 ] // back
+ );
+
+ var retval = { };
+
+ retval.normalObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, normals, ctx.STATIC_DRAW);
+
+ retval.texCoordObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, texCoords, ctx.STATIC_DRAW);
+
+ retval.vertexObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, vertices, ctx.STATIC_DRAW);
+
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, 0);
+
+ retval.indexObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, retval.indexObject);
+ ctx.bufferData(ctx.ELEMENT_ARRAY_BUFFER, indices, ctx.STATIC_DRAW);
+ ctx.bindBuffer(ctx.ELEMENT_ARRAY_BUFFER, 0);
+
+ retval.numIndices = indices.length;
+
+ return retval;
}
-function getGLErrorAsString(ctx, err) {
- if (err === ctx.NO_ERROR)
- return "NO_ERROR";
- for (var name in ctx) {
- if (ctx[name] === err)
- return name;
+//
+// makeSphere
+//
+// Create a sphere with the passed number of latitude and longitude bands and the passed radius.
+// Sphere has vertices, normals and texCoords. Create VBOs for each as well as the index array.
+// Return an object with the following properties:
+//
+// normalObject WebGLBuffer object for normals
+// texCoordObject WebGLBuffer object for texCoords
+// vertexObject WebGLBuffer object for vertices
+// indexObject WebGLBuffer object for indices
+// numIndices The number of indices in the indexObject
+//
+function makeSphere(ctx, radius, lats, longs)
+{
+ var geometryData = [ ];
+ var normalData = [ ];
+ var texCoordData = [ ];
+ var indexData = [ ];
+
+ for (var latNumber = 0; latNumber <= lats; ++latNumber) {
+ for (var longNumber = 0; longNumber <= longs; ++longNumber) {
+ var theta = latNumber * Math.PI / lats;
+ var phi = longNumber * 2 * Math.PI / longs;
+ var sinTheta = Math.sin(theta);
+ var sinPhi = Math.sin(phi);
+ var cosTheta = Math.cos(theta);
+ var cosPhi = Math.cos(phi);
+
+ var x = cosPhi * sinTheta;
+ var y = cosTheta;
+ var z = sinPhi * sinTheta;
+ var u = 1-(longNumber/longs);
+ var v = latNumber/lats;
+
+ normalData.push(x);
+ normalData.push(y);
+ normalData.push(z);
+ texCoordData.push(u);
+ texCoordData.push(v);
+ geometryData.push(radius * x);
+ geometryData.push(radius * y);
+ geometryData.push(radius * z);
+ }
+ }
+
+ longs += 1;
+ for (var latNumber = 0; latNumber < lats; ++latNumber) {
+ for (var longNumber = 0; longNumber < longs; ++longNumber) {
+ var first = (latNumber * longs) + (longNumber % longs);
+ var second = first + longs;
+ indexData.push(first);
+ indexData.push(second);
+ indexData.push(first+1);
+
+ indexData.push(second);
+ indexData.push(second+1);
+ indexData.push(first+1);
+ }
}
- return err.toString();
+
+ var retval = { };
+
+ retval.normalObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.normalObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(normalData), ctx.STATIC_DRAW);
+
+ retval.texCoordObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.texCoordObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(texCoordData), ctx.STATIC_DRAW);
+
+ retval.vertexObject = ctx.createBuffer();
+ ctx.bindBuffer(ctx.ARRAY_BUFFER, retval.vertexObject);
+ ctx.bufferData(ctx.ARRAY_BUFFER, new Float32Array(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 Uint16Array(indexData), ctx.STREAM_DRAW);
+
+ return retval;
}
-function shouldGenerateGLError(ctx, glError, evalStr) {
- var exception;
- try {
- eval(evalStr);
- } catch (e) {
- exception = e;
+//
+// loadObj
+//
+// Load a .obj file from the passed URL. Return an object with a 'loaded' property set to false.
+// When the object load is complete, the 'loaded' property becomes true and the following
+// properties are set:
+//
+// normalObject WebGLBuffer object for normals
+// texCoordObject WebGLBuffer object for texCoords
+// vertexObject WebGLBuffer object for vertices
+// indexObject WebGLBuffer object for indices
+// numIndices The number of indices in the indexObject
+//
+function loadObj(ctx, url)
+{
+ var obj = { loaded : false };
+ obj.ctx = ctx;
+ var req = new XMLHttpRequest();
+ req.obj = obj;
+ req.onreadystatechange = function () { processLoadObj(req) };
+ req.open("GET", url, true);
+ req.send(null);
+ return obj;
+}
+
+function processLoadObj(req)
+{
+ webglTestLog("req="+req)
+ // only if req shows "complete"
+ if (req.readyState == 4) {
+ doLoadObj(req.obj, req.responseText);
}
- if (exception) {
- testFailed(evalStr + " threw exception " + exception);
- } else {
- var err = ctx.getError();
- if (err != glError)
- testFailed(evalStr + " expected GL error: " + getGLErrorAsString(ctx, glError) + ". Generated: " + getGLErrorAsString(ctx, err) + ".");
- else
- testPassed(evalStr + " generated expected GL error: " + getGLErrorAsString(ctx, glError) + ".");
+}
+
+function doLoadObj(obj, text)
+{
+ vertexArray = [ ];
+ normalArray = [ ];
+ textureArray = [ ];
+ indexArray = [ ];
+
+ var vertex = [ ];
+ var normal = [ ];
+ var texture = [ ];
+ var facemap = { };
+ var index = 0;
+
+ var lines = text.split("\n");
+ for (var lineIndex in lines) {
+ var line = lines[lineIndex].replace(/[ \t]+/g, " ").replace(/\s\s*$/, "");
+
+ // ignore comments
+ if (line[0] == "#")
+ continue;
+
+ var array = line.split(" ");
+ if (array[0] == "v") {
+ // vertex
+ vertex.push(parseFloat(array[1]));
+ vertex.push(parseFloat(array[2]));
+ vertex.push(parseFloat(array[3]));
+ }
+ else if (array[0] == "vt") {
+ // normal
+ texture.push(parseFloat(array[1]));
+ texture.push(parseFloat(array[2]));
+ }
+ else if (array[0] == "vn") {
+ // normal
+ normal.push(parseFloat(array[1]));
+ normal.push(parseFloat(array[2]));
+ normal.push(parseFloat(array[3]));
+ }
+ else if (array[0] == "f") {
+ // face
+ if (array.length != 4) {
+ webglTestLog("*** Error: face '"+line+"' not handled");
+ continue;
+ }
+
+ for (var i = 1; i < 4; ++i) {
+ if (!(array[i] in facemap)) {
+ // add a new entry to the map and arrays
+ var f = array[i].split("/");
+ var vtx, nor, tex;
+
+ if (f.length == 1) {
+ vtx = parseInt(f[0]) - 1;
+ nor = vtx;
+ tex = vtx;
+ }
+ else if (f.length = 3) {
+ vtx = parseInt(f[0]) - 1;
+ tex = parseInt(f[1]) - 1;
+ nor = parseInt(f[2]) - 1;
+ }
+ else {
+ webglTestLog("*** Error: did not understand face '"+array[i]+"'");
+ return null;
+ }
+
+ // do the vertices
+ var x = 0;
+ var y = 0;
+ var z = 0;
+ if (vtx * 3 + 2 < vertex.length) {
+ x = vertex[vtx*3];
+ y = vertex[vtx*3+1];
+ z = vertex[vtx*3+2];
+ }
+ vertexArray.push(x);
+ vertexArray.push(y);
+ vertexArray.push(z);
+
+ // do the textures
+ x = 0;
+ y = 0;
+ if (tex * 2 + 1 < texture.length) {
+ x = texture[tex*2];
+ y = texture[tex*2+1];
+ }
+ textureArray.push(x);
+ textureArray.push(y);
+
+ // do the normals
+ x = 0;
+ y = 0;
+ z = 1;
+ if (nor * 3 + 2 < normal.length) {
+ x = normal[nor*3];
+ y = normal[nor*3+1];
+ z = normal[nor*3+2];
+ }
+ normalArray.push(x);
+ normalArray.push(y);
+ normalArray.push(z);
+
+ facemap[array[i]] = index++;
+ }
+
+ indexArray.push(facemap[array[i]]);
+ }
+ }
}
+
+ // 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 Float32Array(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 Float32Array(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 Float32Array(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 Uint16Array(indexArray), obj.ctx.STREAM_DRAW);
+
+ obj.loaded = true;
}
-function assertMsg(assertion, msg) {
- if (assertion) {
- testPassed(msg);
- } else {
- testFailed(msg);
- }
+//
+// loadImageTexture
+//
+// Load the image at the passed url, place it in a new WebGLTexture object and return the WebGLTexture.
+//
+function loadImageTexture(ctx, url)
+{
+ var texture = ctx.createTexture();
+ texture.image = new Image();
+ texture.image.onload = function() { doLoadImageTexture(ctx, texture.image, texture) }
+ texture.image.src = url;
+ return texture;
}
-/**
- * Tests that the first error GL returns is the specified error.
- * @param {!WebGLContext} gl The WebGLContext to use.
- * @param {number} glError The expected gl error.
- * @param {string} opt_msg
- */
-function glErrorShouldBe(gl, glError, opt_msg) {
- opt_msg = opt_msg || "";
- var err = gl.getError();
- if (err != glError) {
- testFailed("getError expected: " + getGLErrorAsString(gl, glError) +
- ". Was " + getGLErrorAsString(gl, err) + " : " + opt_msg);
- } else {
- testPassed("getError was expected value: " +
- getGLErrorAsString(gl, glError) + " : " + opt_msg);
- }
-};
+function doLoadImageTexture(ctx, image, texture)
+{
+ ctx.enable(ctx.TEXTURE_2D);
+ ctx.bindTexture(ctx.TEXTURE_2D, texture);
+ ctx.texImage2D(ctx.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.LINEAR);
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.LINEAR_MIPMAP_LINEAR);
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE);
+ ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE);
+ ctx.generateMipmap(ctx.TEXTURE_2D)
+ ctx.bindTexture(ctx.TEXTURE_2D, 0);
+}
+
+//
+// Framerate object
+//
+// This object keeps track of framerate and displays it as the innerHTML text of the
+// HTML element with the passed id. Once created you call snapshot at the end
+// of every rendering cycle. Every 500ms the framerate is updated in the HTML element.
+//
+Framerate = function(id)
+{
+ this.numFramerates = 10;
+ this.framerateUpdateInterval = 500;
+ this.id = id;
+
+ this.renderTime = -1;
+ this.framerates = [ ];
+ self = this;
+ var fr = function() { self.updateFramerate() }
+ setInterval(fr, this.framerateUpdateInterval);
+}
+
+Framerate.prototype.updateFramerate = function()
+{
+ var tot = 0;
+ for (var i = 0; i < this.framerates.length; ++i)
+ tot += this.framerates[i];
+
+ var framerate = tot / this.framerates.length;
+ framerate = Math.round(framerate);
+ document.getElementById(this.id).innerHTML = "Framerate:"+framerate+"fps";
+}
+
+Framerate.prototype.snapshot = function()
+{
+ if (this.renderTime < 0)
+ this.renderTime = new Date().getTime();
+ else {
+ var newTime = new Date().getTime();
+ var t = newTime - this.renderTime;
+ var framerate = 1000/t;
+ this.framerates.push(framerate);
+ while (this.framerates.length > this.numFramerates)
+ this.framerates.shift();
+ this.renderTime = newTime;
+ }
+}
diff --git a/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html b/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
index 9896d7f..8dbde4b 100644
--- a/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
+++ b/LayoutTests/fast/canvas/webgl/texImage2DImageDataTest.html
@@ -2,7 +2,7 @@
<html>
<head>
<title>texImage2D ImageData Test</title>
- <script src="resources/utils3d.js"> </script>
+ <script src="resources/webgl-test.js"> </script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 vPosition;
attribute vec2 vTexCoord0;
diff --git a/LayoutTests/fast/canvas/webgl/texture-active-bind.html b/LayoutTests/fast/canvas/webgl/texture-active-bind.html
index 167fecf..a7bb250 100644
--- a/LayoutTests/fast/canvas/webgl/texture-active-bind.html
+++ b/LayoutTests/fast/canvas/webgl/texture-active-bind.html
@@ -5,7 +5,7 @@
<title>WebGL ActiveTexture BindTexture conformance test.</title>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
-<script src="resources/utils3d.js"> </script>
+<script src="resources/webgl-test.js"> </script>
</head>
<body>
<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
diff --git a/LayoutTests/fast/canvas/webgl/texture-complete.html b/LayoutTests/fast/canvas/webgl/texture-complete.html
index 47b1924..f445028 100644
--- a/LayoutTests/fast/canvas/webgl/texture-complete.html
+++ b/LayoutTests/fast/canvas/webgl/texture-complete.html
@@ -5,7 +5,7 @@
<title>WebGL "Texture Complete" texture conformance test.</title>
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
-<script src="resources/utils3d.js"> </script>
+<script src="resources/webgl-test.js"> </script>
</head>
<body>
<canvas id="example" width="40" height="40" style="width: 40px; height: 40px;"></canvas>
diff --git a/LayoutTests/fast/canvas/webgl/triangle.html b/LayoutTests/fast/canvas/webgl/triangle.html
index 348e364..46d9b78 100644
--- a/LayoutTests/fast/canvas/webgl/triangle.html
+++ b/LayoutTests/fast/canvas/webgl/triangle.html
@@ -2,7 +2,7 @@
<html>
<head>
<title>Spinning Box</title>
- <script src="resources/utils3d.js"> </script>
+ <script src="resources/webgl-test.js"> </script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
diff --git a/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt b/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
index 30042d9..8a42614 100644
--- a/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
@@ -2,18 +2,18 @@ Tests WebGL APIs related to shader uniforms
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-PASS contextA.useProgram(programA2) is undefined.
-PASS contextA.uniformMatrix4fv(locationA, false, mat) threw exception GL error 1282 in uniformMatrix4fv.
-PASS contextA.useProgram(programA1) is undefined.
-PASS contextA.uniformMatrix4fv(locationA, false, mat) is undefined.
-PASS contextA.uniformMatrix4fv(null, false, mat) is undefined.
-PASS contextA.useProgram(programS) is undefined.
-PASS contextA.uniform1i(locationSx, 3) is undefined.
-PASS contextA.uniform1f(locationArray0, 4.0) is undefined.
+PASS contextA.useProgram(programA2) generated expected GL error: NO_ERROR.
+PASS contextA.uniformMatrix4fv(locationA, false, mat) generated expected GL error: INVALID_OPERATION.
+PASS contextA.useProgram(programA1) generated expected GL error: NO_ERROR.
+PASS contextA.uniformMatrix4fv(locationA, false, mat) generated expected GL error: NO_ERROR.
+PASS contextA.uniformMatrix4fv(null, false, mat) generated expected GL error: NO_ERROR.
+PASS contextA.useProgram(programS) generated expected GL error: NO_ERROR.
+PASS contextA.uniform1i(locationSx, 3) generated expected GL error: NO_ERROR.
+PASS contextA.uniform1f(locationArray0, 4.0) generated expected GL error: NO_ERROR.
PASS contextA.getUniform(programS, locationSx) is 3
PASS contextA.getUniform(programS, locationArray0) is 4.0
-PASS contextA.useProgram(programV) is undefined.
-PASS contextA.uniform4fv(locationVec4, vec) is undefined.
+PASS contextA.useProgram(programV) generated expected GL error: NO_ERROR.
+PASS contextA.uniform4fv(locationVec4, vec) generated expected GL error: NO_ERROR.
PASS contextA.getUniform(programV, locationVec4) is vec
PASS contextA.getUniformLocation(programV, "IDontExist") is null
PASS successfullyParsed is true
diff --git a/LayoutTests/fast/canvas/webgl/uniform-location.html b/LayoutTests/fast/canvas/webgl/uniform-location.html
index dfd2903..06253a9 100644
--- a/LayoutTests/fast/canvas/webgl/uniform-location.html
+++ b/LayoutTests/fast/canvas/webgl/uniform-location.html
@@ -11,8 +11,8 @@
<script>
description("Tests WebGL APIs related to shader uniforms");
-var contextA = create3DDebugContext();
-var contextB = create3DDebugContext();
+var contextA = create3DContext();
+var contextB = create3DContext();
var programA1 = loadStandardProgram(contextA);
var programA2 = loadStandardProgram(contextA);
var programB = loadStandardProgram(contextB);
@@ -27,21 +27,21 @@ var locationVec4 = contextA.getUniformLocation(programV, "fval4");
var vec = [1, 2, 3, 4];
var mat = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
-shouldBeUndefined("contextA.useProgram(programA2)");
-shouldThrow("contextA.uniformMatrix4fv(locationA, false, mat)");
-shouldBeUndefined("contextA.useProgram(programA1)");
-shouldBeUndefined("contextA.uniformMatrix4fv(locationA, false, mat)");
-shouldBeUndefined("contextA.uniformMatrix4fv(null, false, mat)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA2)");
+shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA1)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(locationA, false, mat)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(null, false, mat)");
-shouldBeUndefined("contextA.useProgram(programS)");
-shouldBeUndefined("contextA.uniform1i(locationSx, 3)");
-shouldBeUndefined("contextA.uniform1f(locationArray0, 4.0)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray0, 4.0)");
shouldBe("contextA.getUniform(programS, locationSx)", "3");
shouldBe("contextA.getUniform(programS, locationArray0)", "4.0");
-shouldBeUndefined("contextA.useProgram(programV)");
-shouldBeUndefined("contextA.uniform4fv(locationVec4, vec)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(locationVec4, vec)");
shouldBe("contextA.getUniform(programV, locationVec4)", "vec");
shouldBeNull("contextA.getUniformLocation(programV, \"IDontExist\")");
diff --git a/LayoutTests/fast/canvas/webgl/viewport-unchanged-upon-resize.html b/LayoutTests/fast/canvas/webgl/viewport-unchanged-upon-resize.html
index 83b8ae4..b24d537 100644
--- a/LayoutTests/fast/canvas/webgl/viewport-unchanged-upon-resize.html
+++ b/LayoutTests/fast/canvas/webgl/viewport-unchanged-upon-resize.html
@@ -3,7 +3,6 @@
<link rel="stylesheet" href="../../js/resources/js-test-style.css"/>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
-<script src="resources/utils3d.js"> </script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 g_Position;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list