Merge m-c to bs.

This commit is contained in:
Kyle Huey 2011-03-04 23:54:03 -05:00
commit 8b2b2d95a7
210 changed files with 5375 additions and 1564 deletions

View File

@ -3653,13 +3653,10 @@ function retrieveToolbarIconsizesFromTheme() {
// toolbar. A custom property cannot be used because getComputedStyle can
// only return the values of standard CSS properties.
let counterReset = getComputedStyle(aToolbar).counterReset;
if (counterReset == "smallicons 0") {
if (counterReset == "smallicons 0")
aToolbar.setAttribute("iconsize", "small");
document.persist(aToolbar.id, "iconsize");
} else if (counterReset == "largeicons 0") {
else if (counterReset == "largeicons 0")
aToolbar.setAttribute("iconsize", "large");
document.persist(aToolbar.id, "iconsize");
}
}
Array.forEach(gNavToolbox.childNodes, retrieveToolbarIconsize);

View File

@ -283,7 +283,7 @@ function setupHistory() {
let today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(30);
today.setSeconds(1);
bhist.addPageWithDetails(makeURI("http://today.com/"), "Today", today.valueOf() * 1000);
let lastYear = new Date();
@ -526,7 +526,7 @@ function setupDownloads() {
let today = new Date();
today.setHours(0);
today.setMinutes(0);
today.setSeconds(30);
today.setSeconds(1);
data = {
id: "5555554",

View File

@ -1166,6 +1166,12 @@
]]></handler>
<handler event="click" phase="capturing"><![CDATA[
if (this.getAttribute("disabled") == "true") {
// Prevent the command from being carried out
event.stopPropagation();
return;
}
let node = event.originalTarget;
while (true) {
if (node == this.menuitem)

View File

@ -200,6 +200,7 @@ gTests.push({
itemType: null,
window: null,
_itemId: null,
_cleanShutdown: false,
setup: function() {
// Add a bookmark in unsorted bookmarks folder.
@ -222,31 +223,27 @@ gTests.push({
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
var self = this;
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
this.window.addEventListener("unload", function(event) {
self.window.removeEventListener("unload", arguments.callee, true);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(self._cleanShutdown, "Dialog window should not be closed by pressing Enter on the autocomplete popup");
executeSoon(function () {
self.finish();
}
}
});
}, true);
var popupListener = {
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "popuphidden":
// Everything worked fine, we can stop observing the window.
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", this, true);
self._cleanShutdown = true;
self.window.document.documentElement.cancelDialog();
self.finish();
break;
case "popupshown":
tagsField.popup.removeEventListener("popupshown", this, true);
// In case this test fails the window will close, we should mark the
// failure and continue, to avoid timing out.
ww.registerNotification(windowObserver);
// In case this test fails the window will close, the test will fail
// since we didn't set _cleanShutdown.
var tree = tagsField.popup.tree;
// Focus and select first result.
isnot(tree, null, "Autocomplete results tree exists");
@ -318,12 +315,14 @@ gTests.push({
var namePicker = this.window.document.getElementById("editBMPanel_namePicker");
var userEnteredName = this.window.document.getElementById("editBMPanel_userEnteredName");
var self = this;
this.window.addEventListener("unload", function(event) {
this.window.removeEventListener("unload", arguments.callee, false);
executeSoon(function() {
self.finish();
});
}, false);
self.window.removeEventListener("unload", arguments.callee, false);
executeSoon(function () {
self.finish();
});
}, false);
namePicker.value = "n";
userEnteredName.label = "n";
info("About to focus the namePicker field");
@ -357,6 +356,7 @@ gTests.push({
itemType: null,
window: null,
_itemId: null,
_cleanShutdown: false,
setup: function() {
// Add a bookmark in unsorted bookmarks folder.
@ -379,31 +379,27 @@ gTests.push({
var tagsField = this.window.document.getElementById("editBMPanel_tagsField");
var self = this;
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL) {
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(false, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
this.window.addEventListener("unload", function(event) {
self.window.removeEventListener("unload", arguments.callee, true);
tagsField.popup.removeEventListener("popuphidden", popupListener, true);
ok(self._cleanShutdown, "Dialog window should not be closed by pressing Escape on the autocomplete popup");
executeSoon(function () {
self.finish();
}
}
});
}, true);
var popupListener = {
handleEvent: function(aEvent) {
switch (aEvent.type) {
case "popuphidden":
// Everything worked fine, we can stop observing the window.
ww.unregisterNotification(windowObserver);
tagsField.popup.removeEventListener("popuphidden", this, true);
// Everything worked fine.
self._cleanShutdown = true;
self.window.document.documentElement.cancelDialog();
self.finish();
break;
case "popupshown":
tagsField.popup.removeEventListener("popupshown", this, true);
// In case this test fails the window will close, we should mark the
// failure and continue, to avoid timing out.
ww.registerNotification(windowObserver);
// In case this test fails the window will close, the test will fail
// since we didn't set _cleanShutdown.
var tree = tagsField.popup.tree;
// Focus and select first result.
isnot(tree, null, "Autocomplete results tree exists");
@ -479,16 +475,13 @@ gTests.push({
var folderTree = this.window.document.getElementById("editBMPanel_folderTree");
var self = this;
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowclosed" &&
aSubject.QueryInterface(Ci.nsIDOMWindow).location == DIALOG_URL_MINIMAL_UI) {
ww.unregisterNotification(windowObserver);
ok(self._cleanShutdown,
"Dialog window should not be closed by pressing ESC in folder name textbox");
this.window.addEventListener("unload", function(event) {
self.window.removeEventListener("unload", arguments.callee, true);
ok(self._cleanShutdown, "Dialog window should not be closed by pressing ESC in folder name textbox");
executeSoon(function () {
self.finish();
}
}
ww.registerNotification(windowObserver);
});
}, true);
folderTree.addEventListener("DOMAttrModified", function onDOMAttrModified(event) {
if (event.attrName != "place")

View File

@ -39,44 +39,41 @@
// panels are clickable in both LTR and RTL modes.
function test() {
waitForExplicitFinish();
const BOOKMARKS_SIDEBAR_ID = "viewBookmarksSidebar";
const BOOKMARKS_SIDEBAR_TREE_ID = "bookmarks-view";
const HISTORY_SIDEBAR_ID = "viewHistorySidebar";
const HISTORY_SIDEBAR_TREE_ID = "historyTree";
// Initialization.
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
let bs = PlacesUtils.bookmarks;
let hs = PlacesUtils.history;
let sidebarBox = document.getElementById("sidebar-box");
let sidebar = document.getElementById("sidebar");
waitForExplicitFinish();
const TEST_URL = "http://mochi.test:8888/browser/browser/components/places/tests/browser/sidebarpanels_click_test_page.html";
// If a sidebar is already open, close it.
if (!sidebarBox.hidden) {
if (!document.getElementById("sidebar-box").hidden) {
info("Unexpected sidebar found - a previous test failed to cleanup correctly");
toggleSidebar();
}
const TEST_URL = "http://mochi.test:8888/browser/browser/components/places/tests/browser/sidebarpanels_click_test_page.html";
let sidebar = document.getElementById("sidebar");
let tests = [];
let currentTest;
tests.push({
_itemID: null,
init: function() {
// Add a bookmark to the Unfiled Bookmarks folder.
this._itemID = bs.insertBookmark(bs.unfiledBookmarksFolder,
PlacesUtils._uri(TEST_URL),
bs.DEFAULT_INDEX, "test");
this._itemID = PlacesUtils.bookmarks.insertBookmark(
PlacesUtils.unfiledBookmarksFolderId, PlacesUtils._uri(TEST_URL),
PlacesUtils.bookmarks.DEFAULT_INDEX, "test"
);
},
prepare: function() {
},
selectNode: function(tree) {
tree.selectItems([this._itemID]);
},
cleanup: function() {
bs.removeFolderChildren(bs.unfiledBookmarksFolder);
cleanup: function(aCallback) {
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
executeSoon(aCallback);
},
sidebarName: BOOKMARKS_SIDEBAR_ID,
treeName: BOOKMARKS_SIDEBAR_TREE_ID,
@ -86,11 +83,11 @@ function test() {
tests.push({
init: function() {
// Add a history entry.
this.cleanup();
let uri = PlacesUtils._uri(TEST_URL);
hs.addVisit(uri, Date.now() * 1000, null, hs.TRANSITION_TYPED, false, 0);
let gh = hs.QueryInterface(Ci.nsIGlobalHistory2);
ok(gh.isVisited(uri), "Item is visited");
PlacesUtils.history.addVisit(uri, Date.now() * 1000, null,
PlacesUtils.history.TRANSITION_TYPED,
false, 0);
ok(PlacesUtils.ghistory2.isVisited(uri), "Item is visited");
},
prepare: function() {
sidebar.contentDocument.getElementById("byvisited").doCommand();
@ -100,66 +97,46 @@ function test() {
is(tree.selectedNode.uri, TEST_URL, "The correct visit has been selected");
is(tree.selectedNode.itemId, -1, "The selected node is not bookmarked");
},
cleanup: function() {
hs.QueryInterface(Ci.nsIBrowserHistory)
.removeAllPages();
cleanup: function(aCallback) {
waitForClearHistory(aCallback);
},
sidebarName: HISTORY_SIDEBAR_ID,
treeName: HISTORY_SIDEBAR_TREE_ID,
desc: "History sidebar test"
});
let currentTest;
function testPlacesPanel(preFunc, postFunc) {
currentTest.init();
sidebar.addEventListener("load", function() {
sidebar.removeEventListener("load", arguments.callee, true);
let doc = sidebar.contentDocument;
let tree = doc.getElementById(currentTest.treeName);
let tbo = tree.treeBoxObject;
executeSoon(function() {
currentTest.prepare();
if (preFunc)
preFunc();
function observer(aSubject, aTopic, aData) {
info("alert dialog observed as expected");
os.removeObserver(observer, "common-dialog-loaded");
os.removeObserver(observer, "tabmodal-dialog-loaded");
Services.obs.removeObserver(observer, "common-dialog-loaded");
Services.obs.removeObserver(observer, "tabmodal-dialog-loaded");
aSubject.Dialog.ui.button0.click();
executeSoon(function () {
toggleSidebar(currentTest.sidebarName);
currentTest.cleanup();
postFunc();
currentTest.cleanup(postFunc);
});
}
os.addObserver(observer, "common-dialog-loaded", false);
os.addObserver(observer, "tabmodal-dialog-loaded", false);
Services.obs.addObserver(observer, "common-dialog-loaded", false);
Services.obs.addObserver(observer, "tabmodal-dialog-loaded", false);
let tree = sidebar.contentDocument.getElementById(currentTest.treeName);
// Select the inserted places item.
currentTest.selectNode(tree);
is(tbo.view.selection.count, 1,
"The test node should be successfully selected");
// Get its row ID.
let min = {}, max = {};
tbo.view.selection.getRangeAt(0, min, max);
let rowID = min.value;
tbo.ensureRowIsVisible(rowID);
// Calculate the click coordinates.
let x = {}, y = {}, width = {}, height = {};
tbo.getCoordsForCellItem(rowID, tree.columns[0], "text",
x, y, width, height);
x = x.value + width.value / 2;
y = y.value + height.value / 2;
// Simulate the click.
EventUtils.synthesizeMouse(tree.body, x, y, {}, doc.defaultView);
synthesizeClickOnSelectedTreeCell(tree);
// Now, wait for the observer to catch the alert dialog.
// If something goes wrong, the test will time out at this stage.
// Note that for the history sidebar, the URL itself is not opened,
@ -171,45 +148,69 @@ function test() {
toggleSidebar(currentTest.sidebarName);
}
function synthesizeClickOnSelectedTreeCell(aTree) {
let tbo = aTree.treeBoxObject;
is(tbo.view.selection.count, 1,
"The test node should be successfully selected");
// Get selection rowID.
let min = {}, max = {};
tbo.view.selection.getRangeAt(0, min, max);
let rowID = min.value;
tbo.ensureRowIsVisible(rowID);
// Calculate the click coordinates.
let x = {}, y = {}, width = {}, height = {};
tbo.getCoordsForCellItem(rowID, aTree.columns[0], "text",
x, y, width, height);
x = x.value + width.value / 2;
y = y.value + height.value / 2;
// Simulate the click.
EventUtils.synthesizeMouse(aTree.body, x, y, {},
aTree.ownerDocument.defaultView);
}
function changeSidebarDirection(aDirection) {
document.getElementById("sidebar")
.contentDocument
.documentElement
.style.direction = aDirection;
sidebar.contentDocument.documentElement.style.direction = aDirection;
}
function waitForClearHistory(aCallback) {
Services.obs.addObserver(function(aSubject, aTopic, aData) {
Services.obs.removeObserver(arguments.callee, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
aCallback(aSubject, aTopic, aData);
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
PlacesUtils.bhistory.removeAllPages();
}
function runNextTest() {
// Remove any extraneous tabs.
for (let tabCount = gBrowser.tabContainer.childNodes.length;
tabCount > 1; tabCount--) {
gBrowser.selectedTab = gBrowser.tabContainer.childNodes[tabCount - 1];
gBrowser.removeCurrentTab();
// Remove eventual tabs created by previous sub-tests.
while (gBrowser.tabs.length > 1) {
gBrowser.removeTab(gBrowser.tabContainer.lastChild);
}
if (tests.length == 0)
if (tests.length == 0) {
finish();
}
else {
// Create a new tab for our test to use.
// Create a new tab and run the test.
gBrowser.selectedTab = gBrowser.addTab();
// Now we can run our test.
currentTest = tests.shift();
testPlacesPanel(function() {
changeSidebarDirection("ltr");
info("Running " + currentTest.desc + " in LTR mode");
}, function() {
executeSoon(function() {
testPlacesPanel(function() {
// Run the test in RTL mode.
changeSidebarDirection("rtl");
info("Running " + currentTest.desc + " in RTL mode");
}, function() {
executeSoon(runNextTest);
});
});
});
changeSidebarDirection("ltr");
info("Running " + currentTest.desc + " in LTR mode");
},
function() {
testPlacesPanel(function() {
// Run the test in RTL mode.
changeSidebarDirection("rtl");
info("Running " + currentTest.desc + " in RTL mode");
},
function() {
runNextTest();
});
});
}
}
runNextTest();
// Ensure history is clean before starting the test.
waitForClearHistory(runNextTest);
}

View File

@ -4026,7 +4026,7 @@ SessionStoreService.prototype = {
// Initialize the file output stream.
var ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"].
createInstance(Ci.nsIFileOutputStream);
ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, 0);
ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, ostream.DEFER_OPEN);
// Obtain a converter to convert our data to a UTF-8 encoded input stream.
var converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].

View File

@ -378,9 +378,9 @@ PRBool WebGLContext::ValidateTexFormatAndType(WebGLenum format, WebGLenum type,
PRBool WebGLContext::ValidateAttribIndex(WebGLuint index, const char *info)
{
if (index > mAttribBuffers.Length()) {
if (index >= mAttribBuffers.Length()) {
if (index == WebGLuint(-1)) {
ErrorInvalidValue("%s: index -1 is invalid. That probably comes from a getAttribLication() call, "
ErrorInvalidValue("%s: index -1 is invalid. That probably comes from a getAttribLocation() call, "
"where this return value -1 means that the passed name didn't correspond to an active attribute in "
"the specified program.", info);
} else {

View File

@ -1,5 +1,5 @@
// files that end in .txt list other tests
// other lines are assumed to be .html files
conformance/00_test_list.txt
// files that end in .txt list other tests
// other lines are assumed to be .html files
conformance/00_test_list.txt

View File

@ -1,24 +1,13 @@
This is a local copy of the WebGL conformance suite.
SVN revision: 13113
This is a local copy of the WebGL conformance suite, version 1.0.0.
The canonical location for this testsuite is:
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/
https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/conformance-suites/1.0.0/webgl-conformance-tests.html
All files and directories in this directory, with the exceptions listed below, come from
upstream and should not be modified without corresponding upstream fixes and/or a
patch file in the "patches" directory. The exceptions (the Mozilla-specific files) are:
patch file in this directory. The exceptions (the Mozilla-specific files) are:
* README.mozilla (this file)
* failing_tests.txt
* failing_tests_*.txt
* Makefile.in
* the "mozilla" directory, if any
* the "patches" directory, if any
Moreover, the files named 00_test_list.txt are temporarily renamed to 00_testFIXME_list.txt to work around bug 584611, quote:
> In mochitest, we tell people that mochitests should start with test_. The
> actual truth is that we match anything with a test_ in it.
The "mozilla" directory contains integration of this test suite into Mozilla's
testing system.
* *.patch files, if any

View File

@ -0,0 +1,28 @@
Welcome to the WebGL Conformance Test Suite
===========================================
This is the initial release of the WebGL conformance test suite.
NOTE TO USERS: Unless you are a WebGL implementor, there is no need to submit
a conformance result using this process. Should you discover bugs in your
browser's WebGL implementation, either via this test suite or otherwise,
please report them to your browser vendor's bug tracking system.
FOR WEBGL IMPLEMENTORS: Please follow the isntructions below to create
a formal conformance submission.'
1) Open webgl-conformance-tests.html in your target browser
2) Press the "run tests" button
3) At the end of the run, press "display text summary"
4) Verify that the User Agent and WebGL renderer strings identify your browser and target correctly.
5) Copy the contents of the text summary (starting with "WebGL Conformance Test Results") and send via email to
--- NEED ADDRESS HERE --- @khronos.org
- Version 1.0.0
- February 24, 2011

0
content/canvas/test/webgl/conformance/00_readme.txt Executable file → Normal file
View File

View File

@ -4,9 +4,12 @@ array-unit-tests.html
bad-arguments-test.html
buffer-bind-test.html
buffer-data-array-buffer.html
buffer-preserve-test.html
canvas-test.html
constants.html
context-attributes-alpha-depth-stencil-antialias.html
context-lost-restored.html
context-lost.html
context-type-test.html
copy-tex-image-and-sub-image-2d.html
draw-arrays-out-of-bounds.html
@ -24,7 +27,11 @@ gl-enum-tests.html
gl-get-active-attribute.html
gl-get-active-uniform.html
gl-get-calls.html
gl-getshadersource.html
gl-getstring.html
gl-min-attribs.html
# gl-min-textures.html
gl-min-uniforms.html
gl-object-get-calls.html
gl-pixelstorei.html
gl-scissor-test.html
@ -35,8 +42,9 @@ gl-uniform-bool.html
gl-uniformmatrix4fv.html
gl-unknown-uniform.html
gl-vertex-attrib.html
gl-vertex-attrib-zero-issues.html
gl-vertexattribpointer.html
glsl-2types-of-textures-on-same-unit.html
#glsl-2types-of-textures-on-same-unit.html
glsl-conformance.html
incorrect-context-object-behaviour.html
index-validation-copies-indices.html
@ -44,6 +52,7 @@ index-validation-crash-with-buffer-sub-data.html
index-validation-verifies-too-many-indices.html
index-validation-with-resized-buffer.html
index-validation.html
instanceof-test.html
invalid-UTF-16.html
invalid-passed-params.html
is-object.html
@ -52,6 +61,9 @@ more-than-65536-points.html
null-object-behaviour.html
null-uniform-location.html
object-deletion-behaviour.html
oes-standard-derivatives.html
oes-texture-float.html
oes-vertex-array-object.html
origin-clean-conformance.html
point-size.html
program-test.html
@ -67,6 +79,7 @@ tex-image-and-uniform-binding-bugs.html
tex-image-with-format-and-type.html
tex-image-with-invalid-data.html
tex-input-validation.html
tex-sub-image-2d-bad-args.html
tex-sub-image-2d.html
texparameter-test.html
texture-active-bind-2.html
@ -82,3 +95,5 @@ uniform-samplers-test.html
uninitialized-test.html
viewport-unchanged-upon-resize.html
webgl-specific.html
more/00_test_list.txt

View File

@ -186,6 +186,95 @@ function testConstructWithTypedArrayOfSignedValues(type, name) {
}
}
//
// Test cases for integral types.
// Some JavaScript engines need separate copies of this code in order
// to exercise all of their optimized code paths.
//
function testIntegralArrayTruncationBehavior(type, name, unsigned) {
running('test integral array truncation behavior for ' + name);
var sourceData;
var expectedResults;
if (unsigned) {
sourceData = [0.6, 10.6];
expectedResults = [0, 10];
} else {
sourceData = [0.6, 10.6, -0.6, -10.6];
expectedResults = [0, 10, 0, -10];
}
var numIterations = 10;
var array = new type(numIterations);
// The code block in each of the case statements below is identical, but some
// JavaScript engines need separate copies in order to exercise all of
// their optimized code paths.
try {
switch (type) {
case Int8Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
case Int16Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
case Int32Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
case Uint8Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
case Uint16Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
case Uint32Array:
for (var ii = 0; ii < sourceData.length; ++ii) {
for (var jj = 0; jj < numIterations; ++jj) {
array[jj] = sourceData[ii];
assertEq('Storing ' + sourceData[ii], expectedResults[ii], array[jj]);
}
}
break;
default:
fail("Unhandled type");
break;
}
pass();
} catch (e) {
fail(e);
}
}
//
// Test cases for both signed and unsigned types
//
@ -314,8 +403,8 @@ function negativeTestSetFromArray(type, name) {
}
}
function testSlice(type, name) {
running('test ' + name + ' Slice');
function testSubarray(type, name) {
running('test ' + name + ' Subarray');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
var subarray = array.subarray(0, 5);
@ -334,8 +423,8 @@ function testSlice(type, name) {
}
}
function negativeTestSlice(type, name) {
running('negativeTest ' + name + ' Slice');
function negativeTestSubarray(type, name) {
running('negativeTest ' + name + ' Subarray');
try {
var array = new type([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
subarray = array.subarray(5, 11);
@ -354,17 +443,31 @@ function negativeTestSlice(type, name) {
}
}
function testBoundaryConditions(type, name, lowValue, expectedLowValue, highValue, expectedHighValue) {
running('test ' + name + ' BoundaryConditions(' +
lowValue + ', ' + expectedLowValue + ', ' +
highValue + ', ' + expectedHighValue + ')');
function testSetBoundaryConditions(type, name, testValues, expectedValues) {
running('test ' + name + ' SetBoundaryConditions');
try {
var array = new type(1);
assertEq('Array length', 1, array.length);
array[0] = lowValue;
assertEq('Element 0', expectedLowValue, array[0]);
array[0] = highValue;
assertEq('Element 0', expectedHighValue, array[0]);
for (var ii = 0; ii < testValues.length; ++ii) {
for (var jj = 0; jj < 10; ++jj) {
array[0] = testValues[ii];
assertEq('Element 0', expectedValues[ii], array[0]);
}
}
pass();
} catch (e) {
fail(e);
}
}
function testConstructionBoundaryConditions(type, name, testValues, expectedValues) {
running('test ' + name + ' ConstructionBoundaryConditions');
try {
var array = new type(testValues);
assertEq('Array length', testValues.length, array.length);
for (var ii = 0; ii < testValues.length; ++ii) {
assertEq('Element ' + ii, expectedValues[ii], array[ii]);
}
pass();
} catch (e) {
fail(e);
@ -476,8 +579,8 @@ function testConstructionWithBothArrayBufferAndLength(type, name, elementSizeInB
var array;
var typeSize;
function testSlicingWithOutOfRangeValues(type, name, sz) {
debug("Testing slicing of " + name);
function testSubarrayWithOutOfRangeValues(type, name, sz) {
debug("Testing subarray of " + name);
try {
var buffer = new ArrayBuffer(32);
array = new type(buffer);
@ -497,15 +600,15 @@ function testSlicingWithOutOfRangeValues(type, name, sz) {
shouldBe("array.length", "0");
}
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
testFailed("Subarray of " + name + " threw exception");
}
} catch (e) {
testFailed("Exception: " + e);
}
}
function testSlicingWithDefaultValues(type, name, sz) {
debug("Testing slicing with default inputs of " + name);
function testSubarrayWithDefaultValues(type, name, sz) {
debug("Testing subarray with default inputs of " + name);
try {
var buffer = new ArrayBuffer(32);
array = new type(buffer);
@ -517,7 +620,7 @@ function testSlicingWithDefaultValues(type, name, sz) {
shouldBe("array.subarray(-2).length", "2");
shouldBe("array.subarray(-2147483648).length", "(32 / typeSize)");
} catch (e) {
testFailed("Slicing of " + name + " threw exception");
testFailed("Subarray of " + name + " threw exception");
}
} catch (e) {
testFailed("Exception: " + e);
@ -584,6 +687,81 @@ function negativeTestGetAndSetMethods(type, name) {
}
}
function testNaNConversion(type, name) {
running('test storing NaN in ' + name);
var array = new type([1, 1]);
var results = [];
// The code block in each of the case statements below is identical, but some
// JavaScript engines need separate copies in order to exercise all of
// their optimized code paths.
try {
switch (type) {
case Float32Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Int8Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Int16Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Int32Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Uint8Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Uint16Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
case Uint32Array:
for (var i = 0; i < array.length; ++i) {
array[i] = NaN;
results[i] = array[i];
}
break;
default:
fail("Unhandled type");
break;
}
// Some types preserve NaN values; all other types convert NaN to zero.
if (type === Float32Array) {
assert('initial NaN preserved', isNaN(new type([NaN])[0]));
for (var i = 0; i < array.length; ++i)
assert('NaN preserved via setter', isNaN(results[i]));
} else {
assertEq('initial NaN converted to zero', 0, new type([NaN])[0]);
for (var i = 0; i < array.length; ++i)
assertEq('NaN converted to zero by setter', 0, results[i]);
}
pass();
} catch (e) {
fail(e);
}
}
//
// Test driver
//
@ -596,54 +774,54 @@ function runTests() {
var testCases =
[ {name: "Float32Array",
unsigned: false,
integral: false,
elementSizeInBytes: 4,
low: -500.5,
expectedLow: -500.5,
high: 500.5,
expectedHigh: 500.5},
testValues: [ -500.5, 500.5 ],
expectedValues: [ -500.5, 500.5 ]
},
{name: "Int8Array",
unsigned: false,
integral: true,
elementSizeInBytes: 1,
low: -128,
expectedLow: -128,
high: 127,
expectedHigh: 127},
testValues: [ -128, 127, -129, 128 ],
expectedValues: [ -128, 127, 127, -128 ]
},
{name: "Int16Array",
unsigned: false,
integral: true,
elementSizeInBytes: 2,
low: -32768,
expectedLow: -32768,
high: 32767,
expectedHigh: 32767},
testValues: [ -32768, 32767, -32769, 32768 ],
expectedValues: [ -32768, 32767, 32767, -32768 ]
},
{name: "Int32Array",
unsigned: false,
integral: true,
elementSizeInBytes: 4,
low: -2147483648,
expectedLow: -2147483648,
high: 2147483647,
expectedHigh: 2147483647},
testValues: [ -2147483648, 2147483647, -2147483649, 2147483648 ],
expectedValues: [ -2147483648, 2147483647, 2147483647, -2147483648 ]
},
{name: "Uint8Array",
unsigned: true,
integral: true,
elementSizeInBytes: 1,
low: 0,
expectedLow: 0,
high: 255,
expectedHigh: 255},
testValues: [ 0, 255, -1, 256 ],
expectedValues: [ 0, 255, 255, 0 ]
},
{name: "Uint16Array",
unsigned: true,
integral: true,
elementSizeInBytes: 2,
low: 0,
expectedLow: 0,
high: 65535,
expectedHigh: 65535},
testValues: [ 0, 65535, -1, 65536 ],
expectedValues: [ 0, 65535, 65535, 0 ]
},
{name: "Uint32Array",
unsigned: true,
integral: true,
elementSizeInBytes: 4,
low: 0,
expectedLow: 0,
high: 4294967295,
expectedHigh: 4294967295} ];
testValues: [ 0, 4294967295, -1, 4294967296 ],
expectedValues: [ 0, 4294967295, 4294967295, 0 ]
}
];
for (var i = 0; i < testCases.length; i++) {
var testCase = testCases[i];
running(testCase.name);
@ -662,20 +840,25 @@ function runTests() {
testConstructWithArrayOfSignedValues(type, name);
testConstructWithTypedArrayOfSignedValues(type, name);
}
if (testCase.integral) {
testIntegralArrayTruncationBehavior(type, name, testCase.unsigned);
}
testGetWithOutOfRangeIndices(type, name);
testOffsetsAndSizes(type, name, testCase.elementSizeInBytes);
testSetFromTypedArray(type, name);
negativeTestSetFromTypedArray(type, name);
testSetFromArray(type, name);
negativeTestSetFromArray(type, name);
testSlice(type, name);
negativeTestSlice(type, name);
testBoundaryConditions(type,
name,
testCase.low,
testCase.expectedLow,
testCase.high,
testCase.expectedHigh);
testSubarray(type, name);
negativeTestSubarray(type, name);
testSetBoundaryConditions(type,
name,
testCase.testValues,
testCase.expectedValues);
testConstructionBoundaryConditions(type,
name,
testCase.testValues,
testCase.expectedValues);
testConstructionWithNullBuffer(type, name);
testConstructionWithOutOfRangeValues(type, name);
testConstructionWithNegativeOutOfRangeValues(type, name);
@ -683,12 +866,13 @@ function runTests() {
testConstructionWithUnalignedLength(type, name, testCase.elementSizeInBytes);
testConstructionOfHugeArray(type, name, testCase.elementSizeInBytes);
testConstructionWithBothArrayBufferAndLength(type, name, testCase.elementSizeInBytes);
testSlicingWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
testSlicingWithDefaultValues(type, name, testCase.elementSizeInBytes);
testSubarrayWithOutOfRangeValues(type, name, testCase.elementSizeInBytes);
testSubarrayWithDefaultValues(type, name, testCase.elementSizeInBytes);
testSettingFromArrayWithOutOfRangeOffset(type, name);
testSettingFromFakeArrayWithOutOfRangeLength(type, name);
testSettingFromTypedArrayWithOutOfRangeOffset(type, name);
negativeTestGetAndSetMethods(type, name);
testNaNConversion(type, name);
}
printSummary();

View File

@ -33,6 +33,9 @@ glErrorShouldBe(gl, gl.INVALID_OPERATION);
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
glErrorShouldBe(gl, gl.NO_ERROR);
gl.bufferData(gl.ARRAY_BUFFER, -10, gl.STATIC_DRAW);
glErrorShouldBe(gl, gl.INVALID_VALUE);
// This should not crash, but the selection of the overload is ambiguous per Web IDL.
gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
gl.getError();
@ -42,6 +45,12 @@ glErrorShouldBe(gl, gl.NO_ERROR);
array = new ArrayBuffer(64);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, array);
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, -10, new Float32Array(8));
glErrorShouldBe(gl, gl.INVALID_VALUE);
gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
glErrorShouldBe(gl, gl.NO_ERROR);

View File

@ -0,0 +1,85 @@
<!DOCTYPE HTML>
<html>
<head>
<title>WebGL required buffer clear behaviour test</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
<style type="text/css">
body {
height: 3000px;
}
</style>
<script type="text/javascript">
var iter = 0;
var gl;
var wtu = WebGLTestUtils;
function checkPixel(gl, x, y, c) {
var buf = new Uint8Array(4);
gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
return buf[0] == c[0] &&
buf[1] == c[1] &&
buf[2] == c[2] &&
buf[3] == c[3];
}
function timer() {
if (iter == 0) {
// some random hacky stuff to make sure that we get a compositing step
window.scrollBy(0, 10);
window.scrollBy(0, -10);
iter++;
setTimeout(timer, 500);
} else if (iter == 1) {
// scissor was set earlier
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
wtu.checkCanvasRect(gl, 0, 10, 10, 10, [0, 0, 255, 255], "cleared corner should be blue, stencil should be preserved");
wtu.checkCanvasRect(gl, 0, 0, 10, 10, [0, 0, 0, 0], "remainder of buffer should be cleared");
finishTest();
}
}
function go() {
description("This test ensures WebGL implementations correctly clear the drawing buffer on composite if preserveDrawingBuffer is false.");
debug("");
gl = create3DContext(document.getElementById("c"));
if (!gl) {
finishTest();
return;
}
shouldBeTrue('gl.getContextAttributes().preserveDrawingBuffer == false');
gl.clearColor(1, 0, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
// enable scissor here, before compositing, to make sure it's correctly
// ignored and restored
gl.scissor(0, 10, 10, 10);
gl.enable(gl.SCISSOR_TEST);
setTimeout(timer, 500);
}
window.addEventListener("load", go, false);
successfullyParsed = true;
</script>
</head>
<body>
<div id="description"></div>
<canvas width="20" height="20" style="border: 1px solid blue;" id="c"></canvas>
<div id="console"></div>
</body>
</html>

49
content/canvas/test/webgl/conformance/canvas-test.html Executable file → Normal file
View File

@ -29,6 +29,7 @@ description("This test ensures WebGL implementations interact correctly with the
debug("");
debug("Canvas.getContext");
var err;
var canvas = document.getElementById("canvas");
var canvas2d = document.getElementById("canvas2d");
var ctx2d = canvas2d.getContext("2d");
@ -158,40 +159,34 @@ if (!gl) {
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
checkCanvasContentIs(64, 128, 192, 255);
gl.colorMask(0,0,0,0);
glErrorShouldBe(gl, gl.NO_ERROR, "No GL errors before resizing the canvas");
canvas.width = 400;
canvas.height = 10;
var v = gl.getParameter(gl.COLOR_CLEAR_VALUE);
assertMsg(isAboutEqual(v[0], 0.25) &&
isAboutEqual(v[1], 0.5) &&
isAboutEqual(v[2], 0.75) &&
isAboutEqual(v[3], 1),
"gl.clearColor should not change after canvas resize");
v = gl.getParameter(gl.COLOR_WRITEMASK);
assertMsg(isAboutEqual(v[0], 0) &&
isAboutEqual(v[1], 0) &&
isAboutEqual(v[2], 0) &&
isAboutEqual(v[3], 0),
"gl.colorMask should not change after canvas resize");
shouldBe('getViewport()', '"0,0,300,150"');
checkCanvasContentIs(0, 0, 0, 0);
err = gl.getError();
// Some implementations might lost the context when resizing
if (err != gl.CONTEXT_LOST_WEBGL) {
shouldBe("err", "gl.NO_ERROR");
var v = gl.getParameter(gl.COLOR_CLEAR_VALUE);
assertMsg(isAboutEqual(v[0], 0.25) &&
isAboutEqual(v[1], 0.5) &&
isAboutEqual(v[2], 0.75) &&
isAboutEqual(v[3], 1),
"gl.clearColor should not change after canvas resize");
v = gl.getParameter(gl.COLOR_WRITEMASK);
assertMsg(isAboutEqual(v[0], 0) &&
isAboutEqual(v[1], 0) &&
isAboutEqual(v[2], 0) &&
isAboutEqual(v[3], 0),
"gl.colorMask should not change after canvas resize");
shouldBe('getViewport()', '"0,0,300,150"');
checkCanvasContentIs(0, 0, 0, 0);
}
debug("");
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = finish;
epilogue.src = "../resources/js-test-post.js";
document.body.appendChild(epilogue);
finishTest();
}
}, 1000/30);
}
function finish() {
if (window.nonKhronosFrameworkNotifyDone) {
window.nonKhronosFrameworkNotifyDone();
}
}
</script>
<script>
</script>

View File

@ -245,9 +245,7 @@ LINK_STATUS : 0x8B82,
VALIDATE_STATUS : 0x8B83,
ATTACHED_SHADERS : 0x8B85,
ACTIVE_UNIFORMS : 0x8B86,
ACTIVE_UNIFORM_MAX_LENGTH : 0x8B87,
ACTIVE_ATTRIBUTES : 0x8B89,
ACTIVE_ATTRIBUTE_MAX_LENGTH : 0x8B8A,
SHADING_LANGUAGE_VERSION : 0x8B8C,
CURRENT_PROGRAM : 0x8B8D,
@ -275,7 +273,6 @@ DECR_WRAP : 0x8508,
VENDOR : 0x1F00,
RENDERER : 0x1F01,
VERSION : 0x1F02,
EXTENSIONS : 0x1F03,
/* TextureMagFilter */
NEAREST : 0x2600,
@ -377,8 +374,6 @@ VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
/* Shader Source */
COMPILE_STATUS : 0x8B81,
INFO_LOG_LENGTH : 0x8B84,
SHADER_SOURCE_LENGTH : 0x8B88,
SHADER_COMPILER : 0x8DFA,
/* Shader Precision-Specified Types */

View File

@ -212,18 +212,9 @@ function runTest()
testAntialias(true);
testAntialias(false);
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = finish;
epilogue.src = "../resources/js-test-post.js";
document.body.appendChild(epilogue);
finishTest()
}
function finish() {
if (window.nonKhronosFrameworkNotifyDone) {
window.nonKhronosFrameworkNotifyDone();
}
}
</script>
</head>
<body onload="init()">

View File

@ -0,0 +1,130 @@
<html>
<head>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
<script>
var wtu = WebGLTestUtils;
var canvas;
var gl;
var shouldGenerateGLError;
var extension_name = "WEBKIT_lose_context";
var extension;
var bufferObjects;
var program;
var texture;
var texColor = [255, 10, 20, 255];
function init()
{
if (window.initNonKhronosFramework) {
window.initNonKhronosFramework(true);
}
description("Tests behavior under a restored context");
canvas = document.getElementById("canvas");
canvas.addEventListener("webglcontextlost", testLostContext, false);
canvas.addEventListener("webglcontextrestored", testRestoredContext, false);
gl = wtu.create3DContext(canvas);
shouldGenerateGLError = wtu.shouldGenerateGLError;
extension = gl.getExtension(extension_name);
if (!extension) {
debug(extension_name + " extension not found.");
finish();
return;
}
testOriginalContext();
extension.loseContext();
}
function testRendering()
{
gl.clearColor(0, 0, 0, 255);
gl.colorMask(1, 1, 1, 0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
program = wtu.setupSimpleTextureProgram(gl);
bufferObjects = wtu.setupUnitQuad(gl);
texture = wtu.createColoredTexture(gl, canvas.width, canvas.height, texColor);
gl.uniform1i(gl.getUniformLocation(program, "tex"), 0);
wtu.drawQuad(gl, [0, 0, 0, 255]);
var compare = texColor.slice(0, 3);
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, compare, "shouldBe " + compare);
shouldBe("gl.getError()", "gl.NO_ERROR");
}
function testOriginalContext()
{
debug("Test valid context");
shouldBeFalse("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
testRendering();
debug("");
}
function testLostContext()
{
debug("Test lost context");
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
shouldBe("gl.getError()", "gl.NO_ERROR");
debug("");
}
function testResources(expected)
{
var tests = [
"gl.bindTexture(gl.TEXTURE_2D, texture)",
"gl.useProgram(program)",
"gl.bindBuffer(gl.ARRAY_BUFFER, bufferObjects[0])",
];
for (var i = 0; i < tests.length; ++i)
shouldGenerateGLError(gl, expected, tests[i]);
}
function testRestoredContext()
{
debug("Test restored context");
shouldBeFalse("gl.isContextLost()");
shouldBe("gl.getError()", "gl.NO_ERROR");
// Validate that using old resources fails.
testResources(gl.INVALID_OPERATION);
testRendering();
// Validate new resources created in testRendering().
testResources(gl.NO_ERROR);
debug("");
finish();
}
function finish() {
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = function() {
if (window.nonKhronosFrameworkNotifyDone)
window.nonKhronosFrameworkNotifyDone();
};
epilogue.src = "../resources/js-test-post.js";
document.body.appendChild(epilogue);
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas" width="1px" height="1px"></canvas>
</body>
</html>

View File

@ -0,0 +1,318 @@
<html>
<head>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
<script>
var wtu;
var canvas;
var gl;
var shouldGenerateGLError;
var extension_name = "WEBKIT_lose_context";
var extension;
var buffer;
var framebuffer;
var program;
var renderbuffer;
var shader;
var texture;
var uniformLocation;
var arrayBuffer;
var arrayBufferView
var image;
var video;
var canvas2d;
var ctx2d;
var imageData;
var float32array;
var int32array;
function init()
{
wtu = WebGLTestUtils;
canvas = document.getElementById("canvas");
gl = wtu.create3DContext(canvas);
shouldGenerateGLError = wtu.shouldGenerateGLError;
description("Tests behavior under a lost context");
if (window.initNonKhronosFramework) {
window.initNonKhronosFramework(true);
}
// call testValidContext() before checking for the extension, because this is where we check
// for the isContextLost() method, which we want to do regardless of the extension's presence.
testValidContext();
extension = gl.getExtension(extension_name);
if (!extension) {
debug(extension_name + " extension not found.");
finish();
return;
}
canvas.addEventListener("webglcontextlost", testLostContext, false);
loseContext();
}
function loseContext()
{
debug("");
debug("Lose context");
shouldGenerateGLError(gl, gl.NO_ERROR, "extension.loseContext()");
debug("");
}
function testValidContext()
{
debug("Test valid context");
shouldBeFalse("gl.isContextLost()");
arrayBuffer = new ArrayBuffer(4);
arrayBufferView = new Int8Array(arrayBuffer);
// Generate resources for testing.
buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
framebuffer = gl.createFramebuffer();
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
program = wtu.setupSimpleTextureProgram(gl);
renderbuffer = gl.createRenderbuffer();
gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer);
shader = gl.createShader(gl.VERTEX_SHADER);
texture = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, texture);
shouldBe("gl.getError()", "gl.NO_ERROR");
// Test is queries that will later be false
shouldGenerateGLError(gl, gl.NO_ERROR, "gl.enable(gl.BLEND)");
shouldBeTrue("gl.isBuffer(buffer)");
shouldBeTrue("gl.isEnabled(gl.BLEND)");
shouldBeTrue("gl.isFramebuffer(framebuffer)");
shouldBeTrue("gl.isProgram(program)");
shouldBeTrue("gl.isRenderbuffer(renderbuffer)");
shouldBeTrue("gl.isShader(shader)");
shouldBeTrue("gl.isTexture(texture)");
}
function testLostContext()
{
debug("Test lost context");
// Functions with special return values.
shouldBeTrue("gl.isContextLost()");
shouldBe("gl.getError()", "gl.CONTEXT_LOST_WEBGL");
shouldBe("gl.getError()", "gl.NO_ERROR");
shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_UNSUPPORTED");
shouldBe("gl.getAttribLocation(program, 'u_modelViewProjMatrix')", "-1");
shouldBe("gl.getVertexAttribOffset(0, gl.VERTEX_ATTRIB_ARRAY_POINTER)", "0");
// Test the extension itself.
shouldGenerateGLError(gl, gl.INVALID_OPERATION, "extension.loseContext()");
image = document.createElement("image");
video = document.createElement("video");
canvas2d = document.createElement("canvas");
ctx2d = canvas2d.getContext("2d");
imageData = ctx2d.createImageData(1, 1);
float32array = new Float32Array(1);
int32array = new Int32Array(1);
// Functions returning void should return immediately.
// This is untestable, but we can at least be sure they cause no errors
// and the codepaths are exercised.
var voidTests = [
"gl.activeTexture(gl.TEXTURE0)",
"gl.attachShader(program, shader)",
"gl.bindBuffer(gl.ARRAY_BUFFER, buffer)",
"gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer)",
"gl.bindRenderbuffer(gl.RENDERBUFFER, renderbuffer)",
"gl.bindTexture(gl.TEXTURE_2D, texture)",
"gl.blendColor(1.0, 1.0, 1.0, 1.0)",
"gl.blendEquation(gl.FUNC_ADD)",
"gl.blendEquationSeparate(gl.FUNC_ADD, gl.FUNC_ADD)",
"gl.blendFunc(gl.ONE)",
"gl.blendFuncSeparate(gl.ONE, gl.ONE)",
"gl.bufferData(gl.ARRAY_BUFFER, 0, gl.STATIC_DRAW)",
"gl.bufferData(gl.ARRAY_BUFFER, arrayBufferView, gl.STATIC_DRAW)",
"gl.bufferData(gl.ARRAY_BUFFER, arrayBuffer, gl.STATIC_DRAW)",
"gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBufferView)",
"gl.bufferSubData(gl.ARRAY_BUFFRE, 0, arrayBuffer)",
"gl.clear(gl.COLOR_BUFFER_BIT)",
"gl.clearColor(1, 1, 1, 1)",
"gl.clearDepth(1)",
"gl.clearStencil(0)",
"gl.colorMask(1, 1, 1, 1)",
"gl.compileShader(shader)",
"gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, 0, 0)",
"gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 0, 0)",
"gl.cullFace(gl.FRONT)",
"gl.deleteBuffer(buffer)",
"gl.deleteFramebuffer(framebuffer)",
"gl.deleteProgram(program)",
"gl.deleteRenderbuffer(renderbuffer)",
"gl.deleteShader(shader)",
"gl.deleteTexture(texture)",
"gl.depthFunc(gl.NEVER)",
"gl.depthMask(0)",
"gl.depthRange(0, 1)",
"gl.detachShader(program, shader)",
"gl.disable(gl.BLEND)",
"gl.disableVertexAttribArray(0)",
"gl.drawArrays(gl.POINTS, 0, 0)",
"gl.drawElements(gl.POINTS, 0, gl.UNSIGNED_SHORT, 0)",
"gl.enable(gl.BLEND)",
"gl.enableVertexAttribArray(0)",
"gl.finish()",
"gl.flush()",
"gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, renderbuffer)",
"gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0)",
"gl.frontFace(gl.CW)",
"gl.generateMipmap(gl.TEXTURE_2D)",
"gl.hint(gl.GENERATE_MIPMAP_HINT, gl.FASTEST)",
"gl.lineWidth(0)",
"gl.linkProgram(program)",
"gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, 0)",
"gl.polygonOffset(0, 0)",
"gl.readPixels(0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
"gl.renderbufferStorage(gl.RENDERBUFFER, gl.RGBA4, 0, 0)",
"gl.sampleCoverage(0, 0)",
"gl.scissor(0, 0, 0, 0)",
"gl.shaderSource(shader, '')",
"gl.stencilFunc(gl.NEVER, 0, 0)",
"gl.stencilFuncSeparate(gl.FRONT, gl.NEVER, 0, 0)",
"gl.stencilMask(0)",
"gl.stencilMaskSeparate(gl.FRONT, 0)",
"gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP)",
"gl.stencilOpSeparate(gl.FRONT, gl.KEEP, gl.KEEP, gl.KEEP)",
"gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
"gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData)",
"gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image)",
"gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas)",
"gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, video)",
"gl.texParameterf(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)",
"gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)",
"gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, arrayBufferView)",
"gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, imageData)",
"gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, image)",
"gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, canvas)",
"gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, video)",
"gl.uniform1f(uniformLocation, 0)",
"gl.uniform1fv(uniformLocation, float32array)",
"gl.uniform1fv(uniformLocation, [0])",
"gl.uniform1i(uniformLocation, 0)",
"gl.uniform1iv(uniformLocation, int32array)",
"gl.uniform1iv(uniformLocation, [0])",
"gl.uniform2f(uniformLocation, 0, 0)",
"gl.uniform2fv(uniformLocation, float32array)",
"gl.uniform2fv(uniformLocation, [0, 0])",
"gl.uniform2i(uniformLocation, 0, 0)",
"gl.uniform2iv(uniformLocation, int32array)",
"gl.uniform2iv(uniformLocation, [0, 0])",
"gl.uniform3f(uniformLocation, 0, 0, 0)",
"gl.uniform3fv(uniformLocation, float32array)",
"gl.uniform3fv(uniformLocation, [0, 0, 0])",
"gl.uniform3i(uniformLocation, 0, 0, 0)",
"gl.uniform3iv(uniformLocation, int32array)",
"gl.uniform3iv(uniformLocation, [0, 0, 0])",
"gl.uniform4f(uniformLocation, 0, 0, 0, 0)",
"gl.uniform4fv(uniformLocation, float32array)",
"gl.uniform4fv(uniformLocation, [0, 0, 0, 0])",
"gl.uniform4i(uniformLocation, 0, 0, 0, 0)",
"gl.uniform4iv(uniformLocation, int32array)",
"gl.uniform4iv(uniformLocation, [0, 0, 0, 0])",
"gl.uniformMatrix2fv(uniformLocation, false, float32array)",
"gl.uniformMatrix2fv(uniformLocation, false, [0, 0, 0, 0])",
"gl.uniformMatrix3fv(uniformLocation, false, float32array)",
"gl.uniformMatrix3fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0])",
"gl.uniformMatrix4fv(uniformLocation, false, float32array)",
"gl.uniformMatrix4fv(uniformLocation, false, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])",
"gl.useProgram(program)",
"gl.validateProgram(program)",
"gl.vertexAttrib1f(0, 0)",
"gl.vertexAttrib1fv(0, float32array)",
"gl.vertexAttrib1fv(0, [0])",
"gl.vertexAttrib2f(0, 0, 0)",
"gl.vertexAttrib2fv(0, float32array)",
"gl.vertexAttrib2fv(0, [0, 0])",
"gl.vertexAttrib3f(0, 0, 0, 0)",
"gl.vertexAttrib3fv(0, float32array)",
"gl.vertexAttrib3fv(0, [0, 0, 0])",
"gl.vertexAttrib4f(0, 0, 0, 0, 0)",
"gl.vertexAttrib4fv(0, float32array)",
"gl.vertexAttrib4fv(0, [0, 0, 0, 0])",
"gl.vertexAttribPointer(0, 0, gl.FLOAT, false, 0, 0)",
"gl.viewport(0, 0, 0, 0)",
];
for (var i = 0; i < voidTests.length; ++i) {
shouldGenerateGLError(gl, gl.NO_ERROR, voidTests[i]);
}
// Functions return nullable values should all return null.
var nullTests = [
"gl.createBuffer()",
"gl.createFramebuffer()",
"gl.createProgram()",
"gl.createRenderbuffer()",
"gl.createShader(gl.GL_VERTEX_SHADER)",
"gl.createTexture()",
"gl.getActiveAttrib(program, 0)",
"gl.getActiveUniform(program, 0)",
"gl.getAttachedShaders(program)",
"gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE)",
"gl.getContextAttributes()",
"gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME)",
"gl.getParameter(gl.CURRENT_PROGRAM)",
"gl.getProgramInfoLog(program)",
"gl.getProgramParameter(program, gl.LINK_STATUS)",
"gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH)",
"gl.getShaderInfoLog(shader)",
"gl.getShaderParameter(shader, gl.SHADER_TYPE)",
"gl.getShaderSource(shader)",
"gl.getTexParameter(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S)",
"gl.getUniform(program, uniformLocation)",
"gl.getUniformLocation(program, 'vPosition')",
"gl.getVertexAttrib(0, gl.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING)",
"gl.getSupportedExtensions()",
"gl.getExtension('" + extension_name + "')",
];
for (var i = 0; i < nullTests.length; ++i) {
shouldBeNull(nullTests[i]);
}
// "Is" queries should all return false.
shouldBeFalse("gl.isBuffer(buffer)");
shouldBeFalse("gl.isEnabled(gl.BLEND)");
shouldBeFalse("gl.isFramebuffer(framebuffer)");
shouldBeFalse("gl.isProgram(program)");
shouldBeFalse("gl.isRenderbuffer(renderbuffer)");
shouldBeFalse("gl.isShader(shader)");
shouldBeFalse("gl.isTexture(texture)");
shouldBe("gl.getError()", "gl.NO_ERROR");
finish();
}
function finish() {
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = function() {
if (window.nonKhronosFrameworkNotifyDone)
window.nonKhronosFrameworkNotifyDone();
};
epilogue.src = "../resources/js-test-post.js";
document.body.appendChild(epilogue);
}
</script>
</head>
<body onload="init()">
<div id="description"></div>
<div id="console"></div>
<canvas id="canvas">
</body>
</html>

View File

@ -8,30 +8,7 @@ found in the LICENSE file.
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script id="vshader" type="x-shader/x-vertex">
attribute vec3 g_Position;
attribute vec2 g_TexCoord0;
varying vec2 texCoord;
void main()
{
gl_Position = vec4(g_Position.x, g_Position.y, g_Position.z, 1.0);
texCoord = g_TexCoord0;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D tex;
varying vec2 texCoord;
void main()
{
gl_FragColor = texture2D(tex, texCoord);
}
</script>
<script src="resources/webgl-test-utils.js"></script>
<script>
var successfullyParsed = false;
@ -47,50 +24,20 @@ function init()
runTest();
}
// These two declarations need to be global for "shouldBe" to see them
var pixel = [0, 0, 0];
var correctColor = null;
var gl = null;
var wtu = WebGLTestUtils;
function runTestIteration(antialias)
{
if (antialias)
gl = initWebGL("antialiasOn", "vshader", "fshader", [ "g_Position", "g_TexCoord0" ], [ 0, 0, 0, 1 ], 1);
else
gl = initWebGL("antialiasOff", "vshader", "fshader", [ "g_Position", "g_TexCoord0" ], [ 0, 0, 0, 1 ], 1, { antialias: false });
var canvas = document.getElementById(
antialias ? "antialiasOn" : "antialiasOff");
var attribs = antialias ? { antialias: false } : undefined;
gl = wtu.create3DContext(canvas, attribs);
var program = wtu.setupTexturedQuad(gl);
var textureLoc = gl.getUniformLocation(program, "tex");
glErrorShouldBe(gl, gl.NO_ERROR, "During Initialization");
var textureLoc = gl.getUniformLocation(gl.program, "tex");
var vertices = new Float32Array([
1.0, 1.0, 0.0,
-1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, 1.0, 0.0,
-1.0, -1.0, 0.0,
1.0, -1.0, 0.0]);
var texCoords = new Float32Array([
1.0, 1.0,
0.0, 1.0,
0.0, 0.0,
1.0, 1.0,
0.0, 0.0,
1.0, 0.0]);
var texCoordOffset = vertices.byteLength;
var vbo = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER,
texCoordOffset + texCoords.byteLength,
gl.STATIC_DRAW);
gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices);
gl.bufferSubData(gl.ARRAY_BUFFER, texCoordOffset, texCoords);
gl.enableVertexAttribArray(0);
gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(1);
gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, texCoordOffset);
gl.colorMask(1, 1, 1, 0);
gl.colorMask(1, 1, 1, 1);
gl.disable(gl.BLEND);
debug('Testing copyTexImage2D');
@ -105,64 +52,66 @@ function runTestIteration(antialias)
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 2, 2, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
glErrorShouldBe(gl, gl.NO_ERROR);
gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 0, 0, 2, 2, 0);
glErrorShouldBe(gl, gl.NO_ERROR);
// Green canvas
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Point the uniform sampler to texture unit 0
gl.uniform1i(textureLoc, 0);
// Draw the triangles
gl.drawArrays(gl.TRIANGLES, 0, 6);
// Read back the rendering results, should be red
var buf = new Uint8Array(2 * 2 * 4);
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
var idx = 0;
correctColor = [255, 0, 0];
for (var y = 0; y < 2; y++) {
for (var x = 0; x < 2; x++) {
idx = (y * 2 + x) * 4;
pixel[0] = buf[idx];
pixel[1] = buf[idx + 1];
pixel[2] = buf[idx + 2];
shouldBe("pixel", "correctColor");
var colors = [
[1, 0, 0, 1],
[0, 1, 0, 1],
[0, 0, 1, 1],
[0.5, 0.5, 0.5, 0.5],
];
var count = 0;
for (var yy = -2; yy <= 2; ++yy) {
for (var xx = -2; xx <= 2; ++xx) {
for (var ii = 0; ii < 2; ++ii) {
var texColor = colors[count];
var clearColor = colors[(count + 1) % colors.length];
// clear to some color
gl.clearColor(texColor[0], texColor[1], texColor[2], texColor[3]);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// copy that color to the texture.
switch (ii) {
case 0:
gl.copyTexImage2D(gl.TEXTURE_2D, 0, gl.RGBA, xx, yy, 2, 2, 0);
glErrorShouldBe(gl, gl.NO_ERROR,
"using copyTexImage2D: x =" + xx + ", y = " + yy);
break;
case 1:
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, xx, yy, 2, 2);
glErrorShouldBe(gl, gl.NO_ERROR,
"using copyTexSubImage2D: x =" + xx + ", y = " + yy);
break;
}
// clear to some other color.
gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Draw the triangles
wtu.drawQuad(gl);
// check the rendering results
for (var iy = 0; iy < 2; ++iy) {
for (var ix = 0; ix < 2; ++ix) {
var x = xx + ix;
var y = yy + iy;
var expectedColor = (x < 0 || y < 0 || x >= 2 || y >= 2) ?
[0,0,0,0] :
[Math.floor(255 * texColor[0]),
Math.floor(255 * texColor[1]),
Math.floor(255 * texColor[2]),
Math.floor(255 * texColor[3])];
wtu.checkCanvasRect(gl, ix, iy, 1, 1, expectedColor,
"" + ix + ", " + iy + " should render " + expectedColor + " (+/-1)", 1);
}
}
count = (count + 1) % colors.length;
}
}
}
debug('Testing copyTexSubImage2D');
// Green canvas
gl.clearColor(0, 1, 0, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
glErrorShouldBe(gl, gl.NO_ERROR);
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2);
glErrorShouldBe(gl, gl.NO_ERROR);
// Blue canvas
gl.clearColor(0, 0, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
// Draw the triangles
gl.drawArrays(gl.TRIANGLES, 0, 6);
// Read back the rendering results, should be green
gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, buf);
correctColor = [0, 255, 0];
for (var y = 0; y < 2; y++) {
for (var x = 0; x < 2; x++) {
idx = (y * 2 + x) * 4;
pixel[0] = buf[idx];
pixel[1] = buf[idx + 1];
pixel[2] = buf[idx + 2];
shouldBe("pixel", "correctColor");
}
}
debug("");
}
function runTest(antialias)
@ -172,17 +121,7 @@ function runTest(antialias)
debug("Testing with antialias off");
runTestIteration(false);
successfullyParsed = true;
var epilogue = document.createElement("script");
epilogue.onload = finish;
epilogue.src = "../resources/js-test-post.js";
document.body.appendChild(epilogue);
}
function finish() {
if (window.nonKhronosFrameworkNotifyDone) {
window.nonKhronosFrameworkNotifyDone();
}
finishTest();
}
</script>
</head>

View File

@ -117,13 +117,14 @@ context.enableVertexAttribArray(1);
var ebo = context.createBuffer();
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 0, 1, 2,
1, 2, 0,
2, 0, 1,
200, 200, 200,
0x7fff, 0x7fff, 0x7fff,
0xffff, 0xffff, 0xffff ]),
context.STATIC_DRAW);
context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array(
[ 0, 1, 2,
1, 2, 0,
2, 0, 1,
200, 200, 200,
0x7fff, 0x7fff, 0x7fff,
0xffff, 0xffff, 0xffff ]),
context.STATIC_DRAW);
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 9, context.UNSIGNED_SHORT, 0)");
@ -144,6 +145,27 @@ shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 0, context.UNSIGNED_SHORT, 0)");
// invalid operation with offset that's not a multiple of the type size
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 0)");
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 1)");
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 2)");
// invalid operation if no buffer is bound to ELEMENT_ARRAY_BUFFER
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 0)");
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, ebo);
debug("")
debug("Test buffer setting attrib 0 to a buffer too small and disable it.");
var smallVBO = context.createBuffer();
shouldBeNonNull('smallVBO');
context.bindBuffer(context.ARRAY_BUFFER, smallVBO);
context.bufferData(context.ARRAY_BUFFER, 1, context.STATIC_DRAW);
context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0x10);
context.disableVertexAttribArray(0);
shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 2)");
context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, null);
shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawElements(context.TRIANGLES, 6, context.UNSIGNED_SHORT, 2)");
debug("")
successfullyParsed = true;
</script>

View File

@ -125,7 +125,7 @@ function setBindLocations(colorLocation, positionLocation) {
debug("vPosition:" + gl.getAttribLocation(program, "vPosition"))
debug("vColor :" + gl.getAttribLocation(program, "vColor"))
assertMsg(gl.getAttribLocation(program, "vPosition") == positionLocation,
"location of vPositon should be " + positionLocation);
"location of vPosition should be " + positionLocation);
assertMsg(gl.getAttribLocation(program, "vColor") == colorLocation,
"location of vColor should be " + colorLocation);

View File

View File

View File

@ -55,7 +55,6 @@ if (!gl) {
"gl.isEnabled(desktopGL['CLIP_PLANE0'])",
"gl.isEnabled(desktopGL['POINT_SPRITE'])",
"gl.pixelStorei(desktopGL['PACK_SWAP_BYTES'], 1)",
"gl.readPixels(0, 0, 1, 1, gl.ALPHA, gl.SHORT, buf)",
];
for (var ii = 0; ii < tests.length; ++ii) {
eval(tests[ii]);

View File

@ -122,10 +122,23 @@ else {
shouldBe('context.getParameter(context.UNPACK_FLIP_Y_WEBGL)', 'false');
shouldBe('context.getParameter(context.UNPACK_PREMULTIPLY_ALPHA_WEBGL)', 'false');
shouldBe('context.getParameter(context.VIEWPORT)', '[0, 0, 2, 2]');
shouldBeTrue('context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS) >= 16');
shouldBeTrue('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128');
shouldBeTrue('context.getParameter(context.MAX_VARYING_VECTORS) >= 8');
shouldBe('context.getParameter(context.NUM_COMPRESSED_TEXTURE_FORMATS)', '0');
shouldBeTrue('context.getParameter(context.MAX_COMBINED_TEXTURE_IMAGE_UNITS) >= 8');
shouldBeTrue('context.getParameter(context.MAX_CUBE_MAP_TEXTURE_SIZE) >= 16');
shouldBeTrue('context.getParameter(context.MAX_FRAGMENT_UNIFORM_VECTORS) >= 16');
shouldBeTrue('context.getParameter(context.MAX_RENDERBUFFER_SIZE) >= 1');
shouldBeTrue('context.getParameter(context.MAX_TEXTURE_IMAGE_UNITS) >= 8');
shouldBeTrue('context.getParameter(context.MAX_TEXTURE_SIZE) >= 64');
shouldBeTrue('context.getParameter(context.MAX_VARYING_VECTORS) >= 8');
shouldBeTrue('context.getParameter(context.MAX_VERTEX_ATTRIBS) >= 8');
shouldBeTrue('context.getParameter(context.MAX_VERTEX_TEXTURE_IMAGE_UNITS) >= 0');
shouldBeTrue('context.getParameter(context.MAX_VERTEX_UNIFORM_VECTORS) >= 128');
// Note: This requirement should be removed from the spec IMO. Many impelementations
// will be based on FBOs and FBOs might have a restriction smaller than the current screen size.
// especially if there are multiple screens.
shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[0] >= window.screen.width');
shouldBeTrue('context.getParameter(context.MAX_VIEWPORT_DIMS)[1] >= window.screen.height');
}
debug("");

View File

@ -0,0 +1,45 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
<title>WebGL getShaderSource conformance test.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">abc//def</script>
<script>
description("Tests that the source that goes into a shader is what comes out.");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var original = document.getElementById("vshader").text;
var shader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(shader, original);
var source = gl.getShaderSource(shader);
shouldBe("source", "original");
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors.");
successfullyParsed = true;
</script>
</body>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -0,0 +1,91 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL the minimum number of attributes are supported.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
attribute vec4 v0;
attribute vec4 v1;
attribute vec4 v2;
attribute vec4 v3;
attribute vec4 v4;
attribute vec4 v5;
attribute vec4 v6;
varying vec4 color;
void main()
{
gl_Position = vPosition;
color = v0 + v1 + v2 + v3 + v4 + v5 + v6;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 color;
void main()
{
gl_FragColor = color;
}
</script>
<script>
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var program = wtu.setupTexturedQuad(gl);
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5', 'v6'],
[0, 1, 2, 3, 4, 5, 6, 7]);
for (var ii = 0; ii < 7; ++ii) {
var v = (ii + 1) / 28;
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
v, v/2, v/4, v/8,
v, v/2, v/4, v/8,
v, v/2, v/4, v/8,
v, v/2, v/4, v/8,
v, v/2, v/4, v/8,
v, v/2, v/4, v/8]), gl.STATIC_DRAW);
gl.enableVertexAttribArray(ii + 1);
gl.vertexAttribPointer(ii + 1, 4, gl.FLOAT, false, 0, 0);
}
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 127, 64, 32], "Should render 255,127,64,32 (+/-1)", 1);
successfullyParsed = true;
</script>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -0,0 +1,86 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL the minimum number of uniforms are supported.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#define NUM_TEXTURES 8 // See spec
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D uni[8];
void main()
{
vec4 c = vec4(0,0,0,0);
c += texture2D(uni[0], vec2(0.5, 0.5));
c += texture2D(uni[1], vec2(0.5, 0.5));
c += texture2D(uni[2], vec2(0.5, 0.5));
c += texture2D(uni[3], vec2(0.5, 0.5));
c += texture2D(uni[4], vec2(0.5, 0.5));
c += texture2D(uni[5], vec2(0.5, 0.5));
c += texture2D(uni[6], vec2(0.5, 0.5));
c += texture2D(uni[7], vec2(0.5, 0.5));
gl_FragColor = c;
}
</script>
<script>
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var program = wtu.setupTexturedQuad(gl);
//------------------------------------------------------------------------------
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition'], [0]);
for (var ii = 0; ii < 8; ++ii) {
var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
gl.activeTexture(gl.TEXTURE0 + ii);
var tex = gl.createTexture();
wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0);
gl.uniform1i(loc, ii);
}
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.checkCanvas(gl, [255, 128, 64, 252],
"Should render using all texture units");
successfullyParsed = true;
</script>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -0,0 +1,81 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL the minimum number of uniforms are supported.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#define NUM_TEXTURES 8 // See spec
#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D uni[8];
void main()
{
vec4 c = vec4(0,0,0,0);
for (int ii = 0; ii < NUM_TEXTURES; ++ii) {
c += texture2D(uni[ii], vec2(0.5, 0.5));
}
gl_FragColor = c;
}
</script>
<script>
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var program = wtu.setupTexturedQuad(gl);
//------------------------------------------------------------------------------
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition'], [0]);
for (var ii = 0; ii < 8; ++ii) {
var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
gl.activeTexture(gl.TEXTURE0 + ii);
var tex = gl.createTexture();
wtu.fillTexture(gl, tex, 1, 1, [32, 16, 8, ii * 9], 0);
gl.uniform1i(loc, ii);
}
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.checkCanvas(gl, [255, 128, 64, 252],
"Should render using all texture units");
successfullyParsed = true;
</script>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -0,0 +1,120 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL the minimum number of uniforms are supported.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="4" height="4" style="width: 40px; height: 30px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
#define NUM_UNIFORMS 128 // See spec
attribute vec4 vPosition;
uniform vec4 uni[NUM_UNIFORMS];
varying vec4 color;
void main()
{
gl_Position = vPosition;
vec4 c = vec4(0,0,0,0);
for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
c += uni[ii];
}
color = c;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif
varying vec4 color;
void main()
{
gl_FragColor = color;
}
</script>
<script id="vshader2" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader2" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif
#define NUM_UNIFORMS 16 // See spec
uniform vec4 uni[NUM_UNIFORMS];
void main()
{
vec4 c = vec4(0,0,0,0);
for (int ii = 0; ii < NUM_UNIFORMS; ++ii) {
c += uni[ii];
}
gl_FragColor = vec4(c.r, c.g, c.b, c.a / 120.0);
}
</script>
<script>
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
var program = wtu.setupTexturedQuad(gl);
//------------------------------------------------------------------------------
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition'], [0]);
for (var ii = 0; ii < 128; ++ii) {
var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
gl.uniform4f(loc, 2/256, 2/512, 2/1024, ii/8128);
}
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [255, 127, 64, 255], "Should render 255,127,64,32 (+/-1)", 1);
//------------------------------------------------------------------------------
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader2', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader2', gl.FRAGMENT_SHADER)],
['vPosition'], [0]);
for (var ii = 0; ii < 16; ++ii) {
var loc = gl.getUniformLocation(program, "uni[" + ii + "]");
gl.uniform4f(loc, 16/2048, 16/1024, 16/512, ii);
}
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.drawQuad(gl);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.checkCanvasRect(gl, 0, 0, canvas.width, canvas.height, [32, 64, 127, 255], "Should render 32,64,127,255 (+/-1)", 1);
successfullyParsed = true;
</script>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -10,7 +10,7 @@ are met:
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. AS IS AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
@ -116,12 +116,9 @@ shouldBe('gl.getFramebufferAttachmentParameter(gl.FRAMEBUFFER, gl.DEPTH_ATTACHME
shouldBe('gl.getProgramParameter(standardProgram, gl.DELETE_STATUS)', 'false');
shouldBe('gl.getProgramParameter(standardProgram, gl.LINK_STATUS)', 'true');
shouldBe('typeof gl.getProgramParameter(standardProgram, gl.VALIDATE_STATUS)', '"boolean"');
shouldBe('typeof gl.getProgramParameter(standardProgram, gl.INFO_LOG_LENGTH)', '"number"');
shouldBe('gl.getProgramParameter(standardProgram, gl.ATTACHED_SHADERS)', '2');
shouldBe('gl.getProgramParameter(standardProgram, gl.ACTIVE_ATTRIBUTES)', '2');
shouldBeNonZero('gl.getProgramParameter(standardProgram, gl.ACTIVE_ATTRIBUTE_MAX_LENGTH)');
shouldBe('gl.getProgramParameter(standardProgram, gl.ACTIVE_UNIFORMS)', '1');
shouldBeNonZero('gl.getProgramParameter(standardProgram, gl.ACTIVE_UNIFORM_MAX_LENGTH)');
// Test getRenderbufferParameter
shouldBe('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_WIDTH)', '2');
@ -144,8 +141,6 @@ shouldBeNonZero('gl.getRenderbufferParameter(gl.RENDERBUFFER, gl.RENDERBUFFER_AL
shouldBe('gl.getShaderParameter(standardVert, gl.SHADER_TYPE)', 'gl.VERTEX_SHADER');
shouldBe('gl.getShaderParameter(standardVert, gl.DELETE_STATUS)', 'false');
shouldBe('gl.getShaderParameter(standardVert, gl.COMPILE_STATUS)', 'true');
shouldBe('typeof gl.getShaderParameter(standardVert, gl.INFO_LOG_LENGTH)', '"number"');
shouldBeNonZero('gl.getShaderParameter(standardVert, gl.SHADER_SOURCE_LENGTH)');
// Test getTexParameter
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
@ -211,6 +206,17 @@ shouldBe('gl.getUniform(floatProgram, fvalLoc)', '11');
shouldBe('gl.getUniform(floatProgram, fval2Loc)', '[12, 13]');
shouldBe('gl.getUniform(floatProgram, fval3Loc)', '[14, 15, 16]');
shouldBe('gl.getUniform(floatProgram, fval4Loc)', '[17, 18, 19, 20]');
// Sampler uniform variables
var samplerProgram = loadProgram(gl, "resources/noopUniformShader.vert", "resources/samplerUniformShader.frag");
shouldBe('gl.getProgramParameter(samplerProgram, gl.LINK_STATUS)', 'true');
var s2DValLoc = gl.getUniformLocation(samplerProgram, "s2D");
var sCubeValLoc = gl.getUniformLocation(samplerProgram, "sCube");
gl.useProgram(samplerProgram);
gl.uniform1i(s2DValLoc, 0);
gl.uniform1i(sCubeValLoc, 1);
glErrorShouldBe(gl, gl.NO_ERROR);
shouldBe('gl.getUniform(samplerProgram, s2DValLoc)', '0');
shouldBe('gl.getUniform(samplerProgram, sCubeValLoc)', '1');
// Matrix uniform variables
var matProgram = loadProgram(gl, "resources/matUniformShader.vert", "resources/noopUniformShader.frag");
shouldBe('gl.getProgramParameter(matProgram, gl.LINK_STATUS)', 'true');

View File

121
content/canvas/test/webgl/conformance/gl-teximage.html Executable file → Normal file
View File

@ -39,6 +39,7 @@ var imgURLs = [
'resources/zero-alpha.png',
'resources/3x3.png',
'resources/blue-1x1.jpg',
'resources/red-indexed.png',
'resources/green-2x2-16bit.png',
'resources/small-square-with-colorspin-profile.jpg',
'resources/small-square-with-colorspin-profile.png',
@ -89,19 +90,23 @@ function runTests(imgs) {
color[0] + ", " +
color[1] + ", " +
color[2] + ", " +
color[3] + " was " +
color[3];
var subMsg = " was " +
buf[off + 0] + ", " +
buf[off + 1] + ", " +
buf[off + 2] + ", " +
buf[off + 3];
// When running in WebKit's test harness, we don't want to print the
// pixel value when the test passes, because different machines might
// have different results and we record the text output.
var inDumpRenderTree = window.layoutTestController;
for (var ii = 0; ii < 4; ++ii) {
if (Math.abs(buf[off + ii] - color[ii]) > allowedRange) {
testFailed(msg);
testFailed(msg + subMsg);
return;
}
}
testPassed(msg);
testPassed(msg + (inDumpRenderTree ? "" : subMsg));
}
var tex = gl.createTexture();
@ -207,44 +212,72 @@ function runTests(imgs) {
debug("");
debug("check pixels are UN pre-multiplied");
var canvas2d = document.createElement("canvas");
canvas2d.width = 256;
canvas2d.height = 1;
//canvas2d.style.height = "40px";
//var description = document.getElementById("description");
//description.appendChild(canvas2d);
var ctx = canvas2d.getContext("2d");
ctx.fillRect(0, 0, 256, 1);
ctx.drawImage(imgs['resources/gray-ramp-256-with-128-alpha.png'], 0, 0);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, canvas2d);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.drawQuad(gl);
var ref = new Uint8Array(width * height * 4);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, ref);
var lt128Count = [0, 0, 0];
var ge128Count = [0, 0, 0];
for (var jj = 0; jj < width; ++jj) {
var off = jj * 4;
for (var cc = 0; cc < 3; ++cc) {
if (buf[off + cc] < 128) {
++lt128Count[cc];
} else {
++ge128Count[cc];
for (var ii = 0; ii < 2; ++ii) {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
if (ii == 0) {
var canvas2d = document.createElement("canvas");
canvas2d.width = 256;
canvas2d.height = 1;
var ctx = canvas2d.getContext("2d");
ctx.drawImage(imgs['resources/gray-ramp-256-with-128-alpha.png'], 0, 0);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, canvas2d);
} else {
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
imgs['resources/gray-ramp-256-with-128-alpha.png']);
}
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
wtu.drawQuad(gl);
var buf = new Uint8Array(width * height * 4);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
var lt128Count = [0, 0, 0];
var ge128Count = [0, 0, 0];
for (var jj = 0; jj < width; ++jj) {
var off = jj * 4;
for (var cc = 0; cc < 3; ++cc) {
if (buf[off + cc] < 128) {
++lt128Count[cc];
} else {
++ge128Count[cc];
}
}
}
// Not sure the exact count here because gamma does effect drawing into the
// canvas but it should be close to 50% so I'll pass 45%
for (var jj = 0; jj < 3; ++jj) {
assertMsg(ge128Count[jj] > 256 * 0.45,
"Half the pixels in channel " + jj +
" should be >= 128,128,128. found " +
((ge128Count[jj] / 256) * 100).toFixed() + "%");
assertMsg(lt128Count[jj] > 256 * 0.45,
"Half the pixels in channel " + jj +
" should be < 128,128,128. found " +
((lt128Count[jj] / 256) * 100).toFixed() + "%");
}
}
// Not sure the exact count here because gamma does effect drawing into the
// canvas but it should be close to 50% so I'll pass 45%
for (var jj = 0; jj < 3; ++jj) {
assertMsg(ge128Count[jj] > 256 * 0.45,
"Half the pixels in channel " + jj +
" should be >= 128,128,128. found " +
((ge128Count[jj] / 256) * 100).toFixed() + "%");
assertMsg(lt128Count[jj] > 256 * 0.45,
"Half the pixels in channel " + jj +
" should be < 128,128,128. found " +
((lt128Count[jj] / 256) * 100).toFixed() + "%");
}
debug("");
debug("check canvas pixels are UN pre-multiplied");
var canvas2d = document.createElement("canvas");
canvas2d.width = 1;
canvas2d.height = 1;
var ctx = canvas2d.getContext("2d");
ctx.fillStyle ="rgba(255,255,255,0.5)";
ctx.fillRect(0, 0, 256, 1);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
wtu.drawQuad(gl);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
checkPixelRange(buf, 0, 0, [255, 255, 255, 127], 4);
debug("");
debug("check canvas pixels are pre-multiplied");
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas2d);
wtu.drawQuad(gl);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
checkPixelRange(buf, 0, 0, [127, 127, 127, 127], 4);
debug("");
debug("check pixels are pre-multiplied");
@ -355,6 +388,16 @@ function runTests(imgs) {
assertMsg(same, "uploading PNGs with same data but various ICC profiles should generate the same results");
}
debug("");
debug("check uploading of indexed PNG images");
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE,
imgs['resources/red-indexed.png']);
glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup");
wtu.drawQuad(gl);
gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, buf);
// The image should be red.
checkPixelRange(buf, middle, center, [ 255, 0, 0, 255 ], 10);
debug("");
successfullyParsed = true;
shouldBeTrue("successfullyParsed");

View File

@ -108,13 +108,14 @@ var typeInfos = [
return value === null ? 'null' : value.toString();
},
checkType: function(value) {
return typeof values === 'number';
return typeof value === 'number';
},
checkValue: function(typeInfo, index, value) {
return typeInfo.srcValues[index] == value;
},
srcValues: [16, 15, 14],
srcValuesBad: [],
srcValuesLess: [],
srcValuesNonMultiple: null,
},
{ type: 'vec2',
jsTypeOf: 'Float32Array',
@ -135,8 +136,9 @@ var typeInfos = [
return value === null ? 'null' : ("[" + value[0] + ", " + value[1] + "]");
},
checkType: function(value) {
return typeof values.length === 'number' &&
values.length == 2;
return value &&
typeof value.length === 'number' &&
value.length == 2;
},
checkValue: function(typeInfo, index, value) {
return value !== null &&
@ -144,7 +146,8 @@ var typeInfos = [
typeInfo.srcValues[index * 2 + 1] == value[1];
},
srcValues: [16, 15, 14, 13, 12, 11],
srcValuesBad: [16],
srcValuesLess: [16],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
},
{ type: 'vec3',
jsTypeOf: 'Float32Array',
@ -167,8 +170,9 @@ var typeInfos = [
("[" + value[0] + ", " + value[1] + ", " + value[2] + "]");
},
checkType: function(value) {
return typeof values.length === 'number' &&
values.length == 3;
return value &&
typeof value.length === 'number' &&
value.length == 3;
},
checkValue: function(typeInfo, index, value) {
return value !== null &&
@ -177,7 +181,8 @@ var typeInfos = [
typeInfo.srcValues[index * 3 + 2] == value[2];
},
srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
srcValuesBad: [16, 15],
srcValuesLess: [16, 15],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
},
{ type: 'vec4',
jsTypeOf: 'Float32Array',
@ -202,8 +207,9 @@ var typeInfos = [
", " + value[2] + ", " + value[3] + "]");
},
checkType: function(value) {
return typeof values.length === 'number' &&
values.length == 4;
return value &&
typeof value.length === 'number' &&
value.length == 4;
},
checkValue: function(typeInfo, index, value) {
return value !== null &&
@ -213,7 +219,8 @@ var typeInfos = [
typeInfo.srcValues[index * 4 + 3] == value[3];
},
srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
srcValuesBad: [16, 15, 14],
srcValuesLess: [16, 15, 14],
srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
}
];
@ -233,33 +240,39 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
"uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10");
var loc = gl.getUniformLocation(program, "color[0]");
var srcValues = typeInfo.srcValues;
var srcValuesBad = typeInfo.srcValuesBad;
var srcValuesLess = typeInfo.srcValuesLess;
var srcValuesNonMultiple = typeInfo.srcValuesNonMultiple;
// Try setting the value before using the program
gl[typeInfo.setter](loc, srcValues);
glErrorShouldBe(gl, gl.INVALID_OPERATION,
"should fail if there is no current program");
"should fail if there is no current program");
gl.useProgram(program);
gl[typeInfo.setter](loc, srcValuesBad);
gl[typeInfo.setter](loc, srcValuesLess);
glErrorShouldBe(gl, gl.INVALID_VALUE,
"should fail with insufficient array size with gl." + typeInfo.setter);
"should fail with insufficient array size with gl." + typeInfo.setter);
if (srcValuesNonMultiple) {
gl[typeInfo.setter](loc, srcValuesNonMultiple);
glErrorShouldBe(gl, gl.INVALID_VALUE,
"should fail with non-multiple array size with gl." + typeInfo.setter);
}
gl[typeInfo.setter](loc, srcValues);
glErrorShouldBe(gl, gl.NO_ERROR,
"can set an array of uniforms with gl." + typeInfo.setter);
"can set an array of uniforms with gl." + typeInfo.setter);
var values = gl.getUniform(program, loc);
glErrorShouldBe(gl, gl.NO_ERROR,
"can call gl.getUniform");
"can call gl.getUniform");
assertMsg(typeInfo.checkType(values),
"gl.getUniform returns the correct type.");
for (var ii = 0; ii < typeInfo.numSrcValues; ++ii) {
var elemLoc = gl.getUniformLocation(program, "color[" + ii + "]");
glErrorShouldBe(gl, gl.NO_ERROR,
"can get location of element " + ii +
" of array from gl.getUniformLocation");
"can get location of element " + ii +
" of array from gl.getUniformLocation");
var value = gl.getUniform(program, elemLoc);
glErrorShouldBe(gl, gl.NO_ERROR,
"can get value of element " + ii + " of array from gl.getUniform");
"can get value of element " + ii + " of array from gl.getUniform");
assertMsg(typeInfo.checkValue(typeInfo, ii, value),
"value put in (" + typeInfo.srcValueAsString(ii, srcValues) +
") matches value pulled out (" +
@ -267,7 +280,7 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
}
typeInfo.invalidSet(loc);
glErrorShouldBe(gl, gl.INVALID_OPERATION,
"using the wrong size of gl.Uniform fails");
"using the wrong size of gl.Uniform fails");
var exceptionCaught = false;
if (typeInfo.illegalSet) {
try {
@ -280,7 +293,7 @@ for (var tt = 0; tt < typeInfos.length; ++tt) {
gl.useProgram(null);
glErrorShouldBe(gl, gl.NO_ERROR,
"can call gl.useProgram(null)");
"can call gl.useProgram(null)");
}
debug("");
successfullyParsed = true;

View File

@ -45,7 +45,7 @@ gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ],
var loc = gl.getUniformLocation(gl.program, "color");
gl.uniform1f(loc, 1);
glErrorShouldBe(gl, gl.NO_ERROR,
"should be able to set bool with gl.uniform1f");
"should be able to set bool with gl.uniform1f");
debug("");
successfullyParsed = true;

View File

@ -45,17 +45,24 @@ debug("Checking gl.uniformMatrix.");
gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1);
for (var ii = 2; ii <= 4; ++ii) {
var loc = gl.getUniformLocation(gl.program, "world" + ii);
var mat = [];
var matLess = [];
for (var jj = 0; jj < ii; ++jj) {
for (var ll = 0; ll < ii; ++ll) {
if (jj == ii - 1 && ll == ii - 1)
continue;
mat[jj * ii + ll] = (jj == ll) ? 1 : 0;
matLess[jj * ii + ll] = (jj == ll) ? 1 : 0;
}
}
var mat = matLess.concat([1]);
var matMore = mat.concat([1]);
name = "uniformMatrix" + ii + "fv";
gl[name](loc, false, mat);
gl[name](loc, false, matLess);
glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array size for " + name);
gl[name](loc, false, mat);
glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for " + name);
gl[name](loc, false, matMore);
glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size for " + name);
mat[ii * ii - 1] = 1;
gl[name](loc, false, mat);
glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false");

View File

@ -0,0 +1,97 @@
<!--
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-->
<!DOCTYPE html>
<html>
<head>
<title>WebGL Enable Vertex Attrib Zero Test</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="example" width="50" height="50">
</canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
void main()
{
gl_FragColor = vec4(0.0,0.0,0.0,0.0);
}
</script>
<script>
description("Test some of the issues of the difference between attrib 0 on OpenGL vs WebGL");
debug("");
var wtu = WebGLTestUtils;
var canvas = document.getElementById("example");
var gl = wtu.create3DContext(canvas);
function setup(numVerts, attribIndex) {
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition'], [attribIndex]);
// draw with something on attrib zero with a small number of vertices
var vertexObject = gl.createBuffer();
g_program = program;
g_attribLocation = attribIndex;
shouldBe("g_attribLocation", "gl.getAttribLocation(g_program, 'vPosition')");
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(
gl.ARRAY_BUFFER, new Float32Array(numVerts * 3), gl.STATIC_DRAW);
gl.vertexAttribPointer(attribIndex, 3, gl.FLOAT, false, 0, 0);
var indices = new Uint16Array(numVerts);
for (var ii = 0; ii < numVerts; ++ii) {
indices[ii] = ii;
}
var indexBuffer = gl.createBuffer();
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
return program;
}
var p1 = setup(3, 0);
var p2 = setup(60000, 3);
for (var ii = 0; ii < 5; ++ii) {
gl.useProgram(p1);
gl.enableVertexAttribArray(0);
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
glErrorShouldBe(
gl, gl.NO_ERROR,
"drawing using attrib 0 with 3 verts");
gl.useProgram(p2);
gl.enableVertexAttribArray(3);
gl.drawArrays(gl.LINES, 0, 60000);
glErrorShouldBe(
gl, gl.NO_ERROR,
"drawing using attrib 3 with 60000 verts");
}
wtu.checkCanvas(gl, [0, 0, 0, 0], "canvas should be 0, 0, 0, 0");
successfullyParsed = true;
</script>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -13,6 +13,7 @@ found in the LICENSE file.
<script src="../resources/desktop-gl-constants.js" type="text/javascript"></script>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"></script>
</head>
<body>
<div id="description"></div>
@ -24,6 +25,7 @@ description("This test checks vertexAttribPointer behaviors in WebGL.");
debug("");
debug("Canvas.getContext");
var wtu = WebGLTestUtils;
var gl = create3DContext(document.getElementById("canvas"));
if (!gl) {
testFailed("context does not exist");
@ -33,19 +35,93 @@ if (!gl) {
debug("");
debug("Checking gl.vertexAttribPointer.");
if (!gl.FIXED) {
gl.FIXED = 0x140C;
}
gl.vertexAttribPointer(0, 3, gl.FLOAT, 0, 0, 12);
glErrorShouldBe(gl, gl.INVALID_OPERATION,
"vertexAttribPointer should fail if no buffer is bound");
var vertexObject = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(512), gl.STATIC_DRAW);
gl.vertexAttribPointer(0, 1, gl.FLOAT, 0, 256, 0);
glErrorShouldBe(gl, gl.INVALID_VALUE,
"WebGL API supports vertex attribute data strides up to 255 bytes");
gl.vertexAttribPointer(0, 1, gl.FLOAT, 0, 255, 0);
glErrorShouldBe(gl, gl.NO_ERROR,
"vertexAttribPointer with stride <= 255 should succeed");
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);
gl.vertexAttribPointer(0, 1, gl.INT, 0, 0, 0);
glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support INT");
gl.vertexAttribPointer(0, 1, gl.UNSIGNED_INT, 0, 0, 0);
glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support UNSIGNED_INT");
gl.vertexAttribPointer(0, 1, gl.FIXED, 0, 0, 0);
glErrorShouldBe(gl, gl.INVALID_ENUM,
"vertexAttribPointer should not support FIXED");
function checkVertexAttribPointer(
gl, err, reason, size, type, normalize, stride, offset) {
gl.vertexAttribPointer(0, size, type, normalize, stride, offset);
glErrorShouldBe(gl, err,
"gl.vertexAttribPointer(0, " + size +
", gl." + wtu.glEnumToString(gl, type) +
", " + normalize +
", " + stride +
", " + offset +
") should " + (err == gl.NO_ERROR ? "succeed " : "fail ") + reason);
}
var types = [
{ type:gl.BYTE, bytesPerComponent: 1 },
{ type:gl.UNSIGNED_BYTE, bytesPerComponent: 1 },
{ type:gl.SHORT, bytesPerComponent: 2 },
{ type:gl.UNSIGNED_SHORT, bytesPerComponent: 2 },
{ type:gl.FLOAT, bytesPerComponent: 4 },
];
for (var ii = 0; ii < types.length; ++ii) {
var info = types[ii];
debug("");
for (var size = 1; size <= 4; ++size) {
debug("");
debug("checking: " + wtu.glEnumToString(gl, info.type) + " with size " + size);
var bytesPerElement = size * info.bytesPerComponent;
var offsetSet = [
0,
1,
info.bytesPerComponent - 1,
info.bytesPerComponent,
info.bytesPerComponent + 1,
info.bytesPerComponent * 2];
for (var jj = 0; jj < offsetSet.length; ++jj) {
var offset = offsetSet[jj];
for (var kk = 0; kk < offsetSet.length; ++kk) {
var stride = offsetSet[kk];
var err = gl.NO_ERROR;
var reason = ""
if (offset % info.bytesPerComponent != 0) {
reason = "because offset is bad";
err = gl.INVALID_OPERATION;
}
if (stride % info.bytesPerComponent != 0) {
reason = "because stride is bad";
err = gl.INVALID_OPERATION;
}
checkVertexAttribPointer(
gl, err, reason, size, info.type, false, stride, offset);
}
var stride = Math.floor(255 / info.bytesPerComponent) * info.bytesPerComponent;
if (offset == 0) {
checkVertexAttribPointer(
gl, gl.NO_ERROR, "at stride limit",
size, info.type, false, stride, offset);
checkVertexAttribPointer(
gl, gl.INVALID_VALUE, "over stride limit",
size, info.type, false,
stride + info.bytesPerComponent, offset);
}
}
}
}
}
debug("");

View File

@ -100,6 +100,17 @@ void main()
foo
#endif
</script>
<script id="fshaderWithUndefinedPreprocessorSymbol" type="text/something-not-javascript">
#if UNDEFINED_FOO
// according to ES GLSL spec 3.4 undefined symbols should fail.
#else
precision mediump float;
void main()
{
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
}
#endif
</script>
<script id="fshaderWithFragDepth" type="text/something-not-javascript">
precision mediump float;
void main()
@ -223,6 +234,16 @@ foo
<script id="vshaderWith__FILE__" type="text/something-not-javascript">
__FILE__
</script>
<script id="vshaderWithIncludeDirective" type="text/something-not-javascript">
// Sadly I can not force the current path so this could fail beacuse include.vs
// does not exist, not because #include is disallowed.
#include "include.vs"
attribute vec4 vPosition;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshaderWithdFdx" type="text/something-not-javascript">
#extension GL_OES_standard_derivatives:enable
precision mediump float;
@ -240,7 +261,7 @@ void main()
</script>
<script id="fshaderWith256CharacterIdentifier" type="text/something-not-javascript">
precision mediump float;
uniform float a123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345 = 2.0;
uniform float a123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345;
void main()
{
gl_FragColor = vec4(a123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345,0.0,0.0,1.0);
@ -248,12 +269,44 @@ void main()
</script>
<script id="fshaderWith257CharacterIdentifier" type="text/something-not-javascript">
precision mediump float;
uniform float a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 = 2.0;
uniform float a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456;
void main()
{
gl_FragColor = vec4(a1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456,0.0,0.0,1.0);
}
</script>
<script id="fshaderWithLongLine" type="text/something-not-javascript">
precision mediump float;
uniform float fooo;
#if defined(someSymbolNotDefined)
#error long
#endif
void main()
{
gl_FragColor = vec4(fooo+fooo+fooo+fooo, fooo+fooo+fooo+fooo, fooo+fooo+fooo+fooo, 1.0);
}
</script>
<script id="fshaderWithErrorDirective" type="text/something-not-javascript">
#error testing123 testing123
void main()
{
gl_FragColor = vec4(0,0,0,0);
}
</script>
<script id="fshaderWithQuotedErrorDirective" type="text/something-not-javascript">
#error "testing123 testing123" // will return INVALID_VALUE. See WebGL 6.18
void main()
{
gl_FragColor = vec4(0,0,0,0);
}
</script>
<script id="fshaderWithNonASCIIErrorDirective" type="text/something-not-javascript">
#error これはASCIIではない // will return INVALID_VALUE. See WebGL 6.18
void main()
{
gl_FragColor = vec4(0,0,0,0);
}
</script>
<canvas id="canvas" width="2" height="2"> </canvas>
<script>
description("This test ensures WebGL implementations allow proper GLES2 shaders compile and improper ones fail.");
@ -334,6 +387,13 @@ if (!gl) {
linkSuccess: true,
passMsg: 'fragment shader that uses __VERSION__==100 should succeed',
},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWithUndefinedPreprocessorSymbol',
fShaderSuccess: false,
linkSuccess: false,
passMsg: 'fragment shader undefined preprocessor symbol should fail (3.4)',
},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWithFragDepth',
@ -461,23 +521,72 @@ if (!gl) {
linkSuccess: false,
passMsg: 'vertex shader uses #line directive should report correct line',
},
// TODO(zmo): adding these tests back once the limit is added to WebGL spec.
/*
{ vShaderId: 'vshaderWithIncludeDirective',
vShaderSuccess: false,
fShaderId: 'fshader',
fShaderSuccess: true,
linkSuccess: false,
passMsg: 'vertex shader uses #include should fail',
},
//{ vShaderId: 'vshader',
// vShaderSuccess: true,
// fShaderId: 'fshaderWith257CharacterIdentifier',
// fShaderSuccess: false,
// linkSuccess: false,
// passMsg: 'shader that uses 257 character identifier should fail',
//},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWith256CharacterIdentifier',
fShaderSuccess: true,
linkSuccess: true,
passMsg: 'shared that uses 256 character identifier should succeed',
passMsg: 'shader that uses 256 character identifier should succeed',
},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWith257CharacterIdentifier',
fShaderId: 'fshaderWithLongLine',
fShaderSuccess: true,
fShaderPrep: function(str) {
function expand(str, re, replacement, count) {
for (var ii = 0; ii < count; ++ii) {
str = str.replace(re, replacement);
}
return str;
}
str = expand(str, new RegExp(" ", 'g'), " ", 12);
str = expand(str, new RegExp("0", 'g'), "00", 8);
str = expand(str, new RegExp("fooo", 'g'), "fooofooo", 6);
str = expand(str, new RegExp("long", 'g'), "longlong", 6);
//debug("len:" + str.length);
//debug(str);
return str;
},
linkSuccess: true,
passMsg: 'shader that uses long lines should succeed',
},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWithErrorDirective',
fShaderSuccess: false,
fShaderTest: (function() {
return wtu.getLastError().indexOf("testing123 testing123") >= 0; }),
linkSuccess: false,
passMsg: "error directive returns error user's error message",
},
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWithQuotedErrorDirective',
fShaderSuccess: false,
linkSuccess: false,
passMsg: 'shared that uses 257 character identifier should fail',
passMsg: "error directive using quotes fails",
},
*/
{ vShaderId: 'vshader',
vShaderSuccess: true,
fShaderId: 'fshaderWithNonASCIIErrorDirective',
fShaderSuccess: false,
linkSuccess: false,
passMsg: "error directive using characters outside of allowed set fails",
}
];
// Read in all the shader source.
@ -548,7 +657,9 @@ if (!gl) {
info.passMsg
log(passMsg);
//debug(info.fShaderId);
var vShader = wtu.loadShader(gl, info.vShaderSource, gl.VERTEX_SHADER);
var vSource = info.vShaderPrep ? info.vShaderPrep(info.vShaderSource) :
info.vShaderSource;
var vShader = wtu.loadShader(gl, vSource, gl.VERTEX_SHADER);
if (info.vShaderTest) {
if (!info.vShaderTest(vShader)) {
testFailed(passMsg);
@ -559,7 +670,15 @@ if (!gl) {
testFailed(passMsg);
continue;
}
var fShader = wtu.loadShader(gl, info.fShaderSource, gl.FRAGMENT_SHADER);
var fSource = info.fShaderPrep ? info.fShaderPrep(info.fShaderSource) :
info.fShaderSource;
var fShader = wtu.loadShader(gl, fSource, gl.FRAGMENT_SHADER);
if (info.fShaderTest) {
if (!info.fShaderTest(fShader)) {
testFailed(passMsg);
continue;
}
}
//debug(fShader == null ? "fail" : "succeed");
if ((fShader != null) != info.fShaderSuccess) {
testFailed(passMsg);
@ -573,7 +692,7 @@ if (!gl) {
gl.linkProgram(program);
var linked = (gl.getProgramParameter(program, gl.LINK_STATUS) != 0);
if (!linked) {
var error = gl.getProgramInfoLog(shader);
var error = gl.getProgramInfoLog(program);
log("*** Error linking program '"+program+"':"+error);
}
if (linked != info.linkSuccess) {

View File

@ -0,0 +1,4 @@
// Do not delete!
// Needed to help glsl-conformance tests.

View File

@ -126,7 +126,9 @@ debug("Enable an extra attribute with insufficient data buffer");
gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
glErrorShouldBe(gl, gl.NO_ERROR);
shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
successfullyParsed = true;
</script>

View File

@ -0,0 +1,97 @@
<!--
Copyright (c) 2009 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>WebGL instanceof test.</title>
<link rel="stylesheet" href="../resources/js-test-style.css"/>
<script src="../resources/js-test-pre.js"></script>
<script src="resources/webgl-test.js"> </script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<canvas id="canvas" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
<div id="description"></div>
<div id="console"></div>
<script id="vshader" type="x-shader/x-vertex">
attribute vec4 vPosition;
varying vec2 texCoord;
void main()
{
gl_Position = vPosition;
}
</script>
<script id="fshader" type="x-shader/x-fragment">
#ifdef GL_ES
precision mediump float;
#endif
uniform vec4 color;
void main()
{
gl_FragColor = color;
}
</script>
<script>
var wtu = WebGLTestUtils;
debug("Tests that instanceof works on WebGL objects.");
debug("");
var gl = create3DContext(document.getElementById("canvas"));
shouldBeTrue('gl instanceof WebGLRenderingContext');
shouldBeTrue('gl.createBuffer() instanceof WebGLBuffer');
shouldBeTrue('gl.createFramebuffer() instanceof WebGLFramebuffer');
shouldBeTrue('gl.createProgram() instanceof WebGLProgram');
shouldBeTrue('gl.createRenderbuffer() instanceof WebGLRenderbuffer');
shouldBeTrue('gl.createShader(gl.VERTEX_SHADER) instanceof WebGLShader');
shouldBeTrue('gl.createTexture() instanceof WebGLTexture');
var program = wtu.setupProgram(
gl,
[wtu.loadShaderFromScript(gl, 'vshader', gl.VERTEX_SHADER),
wtu.loadShaderFromScript(gl, 'fshader', gl.FRAGMENT_SHADER)],
['vPosition'], [0]);
shouldBeTrue('gl.getUniformLocation(program, "color") instanceof WebGLUniformLocation');
shouldBeTrue('gl.getActiveAttrib(program, 0) instanceof WebGLActiveInfo');
shouldBeTrue('gl.getActiveUniform(program, 0) instanceof WebGLActiveInfo');
debug("");
debug("Tests that those WebGL objects can not be constructed through new operator");
debug("");
function shouldThrowWithNew(objectType, objectName)
{
try {
new objectType;
testFailed('new ' + objectName + ' did not throw');
} catch (e) {
testPassed('new ' + objectName + ' threw an error');
}
}
shouldThrowWithNew(WebGLRenderingContext, 'WebGLRenderingContext');
shouldThrowWithNew(WebGLActiveInfo, 'WebGLActiveInfo');
shouldThrowWithNew(WebGLBuffer, 'WebGLBuffer');
shouldThrowWithNew(WebGLFramebuffer, 'WebGLFramebuffer');
shouldThrowWithNew(WebGLProgram, 'WebGLProgram');
shouldThrowWithNew(WebGLRenderbuffer, 'WebGLRenderbuffer');
shouldThrowWithNew(WebGLShader, 'WebGLShader');
shouldThrowWithNew(WebGLTexture, 'WebGLTexture');
shouldThrowWithNew(WebGLUniformLocation, 'WebGLUniformLocation');
successfullyParsed = true;
</script>
</body>
<script src="../resources/js-test-post.js"></script>
<script>
</script>
</body>
</html>

View File

@ -38,18 +38,21 @@ description("Test for invalid passed parameters");
var context = create3DContext();
debug("");
debug("Test createShader()");
shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.FRAGMENT_SHADER)");
shouldGenerateGLError(context, context.NO_ERROR, "context.createShader(context.VERTEX_SHADER)");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(0)");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.createShader(context.TRIANGLES)");
debug("");
debug("Test clear()");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'])");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.clear(desktopGL['ACCUM_BUFFER_BIT'] | context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
shouldGenerateGLError(context, context.NO_ERROR, "context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT | context.STENCIL_BUFFER_BIT)");
debug("");
debug("Test bufferData()");
var buffer = context.createBuffer();
shouldGenerateGLError(context, context.NO_ERROR, "context.bindBuffer(context.ARRAY_BUFFER, buffer)");
@ -63,6 +66,119 @@ shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_READ'])");
shouldGenerateGLError(context, context.INVALID_ENUM, "context.bufferData(context.ARRAY_BUFFER, 16, desktopGL['DYNAMIC_COPY'])");
debug("");
debug("Test {copy}Tex{Sub}Image2D with negative offset/width/height");
var tex = context.createTexture();
var pixels = new Uint8Array(2 * 2 * 4);
shouldGenerateGLError(context, context.NO_ERROR, "context.bindTexture(context.TEXTURE_2D, tex)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, -16, -16, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
shouldGenerateGLError(context, context.NO_ERROR, "context.texImage2D(context.TEXTURE_2D, 0, context.RGBA, 16, 16, 0, context.RGBA, context.UNSIGNED_BYTE, null)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, -1, -1, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, -1, -1, context.RGBA, context.UNSIGNED_BYTE, pixels)");
shouldGenerateGLError(context, context.NO_ERROR, "context.texSubImage2D(context.TEXTURE_2D, 0, 0, 0, 2, 2, context.RGBA, context.UNSIGNED_BYTE, pixels)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, -1, -1, 0)");
shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexImage2D(context.TEXTURE_2D, 0, context.RGBA, 0, 0, 16, 16, 0)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, -1, -1, 0, 0, 2, 2)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, -1, -1)");
shouldGenerateGLError(context, context.NO_ERROR, "context.copyTexSubImage2D(context.TEXTURE_2D, 0, 0, 0, 0, 0, 2, 2)");
debug("");
debug("Test renderbufferStorage() with negative width/height");
var renderbuffer = context.createRenderbuffer();
shouldGenerateGLError(context, context.NO_ERROR, "context.bindRenderbuffer(context.RENDERBUFFER, renderbuffer)");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, -2, -2)");
shouldGenerateGLError(context, context.NO_ERROR, "context.renderbufferStorage(context.RENDERBUFFER, context.RGBA4, 16, 16)");
debug("");
debug("Test scissor() with negative width/height");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.scissor(0, 0, -2, -2)");
shouldGenerateGLError(context, context.NO_ERROR, "context.scissor(0, 0, 16, 16)");
debug("");
debug("Test viewport() with negative width/height");
shouldGenerateGLError(context, context.INVALID_VALUE, "context.viewport(0, 0, -2, -2)");
shouldGenerateGLError(context, context.NO_ERROR, "context.viewport(0, 0, 16, 16)");
debug("");
debug("Set up a program to test invalid characters");
var invalidSet = ['"', '$', '`', '@', '\\', "'"];
var validUniformName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_1234567890";
var validAttribName = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
function generateShaderSource(opt_invalidIdentifierChar, opt_invalidCommentChar) {
var invalidIdentifierString = "";
var invalidCommentString = "";
if (opt_invalidIdentifierChar != undefined) {
invalidIdentifierString += opt_invalidIdentifierChar;
}
if (opt_invalidCommentChar != undefined) {
invalidCommentString += opt_invalidCommentChar;
}
return "uniform float " + validUniformName + invalidIdentifierString + ";\n"
+ "varying float " + validAttribName + ";\n"
+ "void main() {\n"
+ validAttribName + " = " + validUniformName + ";\n"
+ "gl_Position = vec4(0.0, 0.0, 0.0, 1.0); }\n";
+ "//.+-/*%<>[](){}^|&~=!:;,?# " + invalidCommentString;
}
var vShader = context.createShader(context.VERTEX_SHADER);
context.shaderSource(vShader, generateShaderSource());
context.compileShader(vShader);
shouldBe("context.getError()", "context.NO_ERROR");
var fShader = context.createShader(context.FRAGMENT_SHADER);
context.shaderSource(fShader, "precision highp float;\n"
+ "varying float " + validAttribName + ";\n"
+ "void main() {\n"
+ "gl_FragColor = vec4(" + validAttribName + ", 0.0, 0.0, 1.0); }");
context.compileShader(fShader);
shouldBe("context.getError()", "context.NO_ERROR");
var program = context.createProgram();
context.attachShader(program, vShader);
context.attachShader(program, fShader);
context.linkProgram(program);
shouldBeTrue("context.getProgramParameter(program, context.LINK_STATUS)");
shouldBe("context.getError()", "context.NO_ERROR");
context.bindAttribLocation(program, 1, validAttribName);
shouldBe("context.getError()", "context.NO_ERROR");
context.getAttribLocation(program, validAttribName);
shouldBe("context.getError()", "context.NO_ERROR");
context.getUniformLocation(program, validUniformName);
shouldBe("context.getError()", "context.NO_ERROR");
debug("");
debug("Test shaderSource() with invalid characters");
for (var i = 0; i < invalidSet.length; ++i) {
var validShaderSource = generateShaderSource(undefined, invalidSet[i]);
context.shaderSource(vShader, validShaderSource);
shouldBe("context.getError()", "context.NO_ERROR");
var invalidShaderSource = generateShaderSource(invalidSet[i], undefined);
context.shaderSource(vShader, invalidShaderSource);
shouldBe("context.getError()", "context.INVALID_VALUE");
}
debug("");
debug("Test bindAttribLocation() with invalid characters");
for (var i = 0; i < invalidSet.length; ++i) {
var invalidName = validAttribName + invalidSet[i];
context.bindAttribLocation(program, 1, invalidName);
shouldBe("context.getError()", "context.INVALID_VALUE");
}
debug("");
debug("Test getAttribLocation() with invalid characters");
for (var i = 0; i < invalidSet.length; ++i) {
var invalidName = validAttribName + invalidSet[i];
context.getAttribLocation(program, invalidName);
shouldBe("context.getError()", "context.INVALID_VALUE");
}
debug("");
debug("Test getUniformLocation() with invalid characters");
for (var i = 0; i < invalidSet.length; ++i) {
var invalidName = validUniformName + invalidSet[i];
context.getUniformLocation(program, invalidName);
shouldBe("context.getError()", "context.INVALID_VALUE");
}
debug("")
successfullyParsed = true;
</script>

View File

@ -1,10 +1,7 @@
conformance/badArgsArityLessThanArgc.html
conformance/constants.html
# conformance/fuzzTheAPI.html // No interactive tests.
conformance/getContext.html
conformance/methods.html
conformance/quickCheckAPI.html
conformance/quickCheckAPIBadArgs.html
#conformance/quickCheckAPI.html
conformance/webGLArrays.html
functions/bindBuffer.html
functions/bindBufferBadArgs.html
@ -22,8 +19,6 @@ functions/drawArrays.html
functions/drawArraysOutOfBounds.html
functions/drawElements.html
functions/drawElementsBadArgs.html
functions/getImageData.html
functions/getImageDataBadArgs.html
functions/isTests.html
functions/readPixels.html
functions/readPixelsBadArgs.html
@ -37,6 +32,7 @@ functions/texSubImage2DHTML.html
functions/texSubImage2DHTMLBadArgs.html
functions/uniformf.html
functions/uniformfBadArgs.html
functions/uniformfArrayLen1.html
functions/uniformi.html
functions/uniformiBadArgs.html
functions/uniformMatrix.html

View File

@ -165,7 +165,7 @@ UNSIGNED_SHORT : 0x1403,
INT : 0x1404,
UNSIGNED_INT : 0x1405,
FLOAT : 0x1406,
FIXED : 0x140C,
//FIXED : 0x140C,
DEPTH_COMPONENT : 0x1902,
ALPHA : 0x1906,
RGB : 0x1907,
@ -190,9 +190,7 @@ LINK_STATUS : 0x8B82,
VALIDATE_STATUS : 0x8B83,
ATTACHED_SHADERS : 0x8B85,
ACTIVE_UNIFORMS : 0x8B86,
ACTIVE_UNIFORM_MAX_LENGTH : 0x8B87,
ACTIVE_ATTRIBUTES : 0x8B89,
ACTIVE_ATTRIBUTE_MAX_LENGTH : 0x8B8A,
SHADING_LANGUAGE_VERSION : 0x8B8C,
CURRENT_PROGRAM : 0x8B8D,
NEVER : 0x0200,
@ -213,7 +211,7 @@ DECR_WRAP : 0x8508,
VENDOR : 0x1F00,
RENDERER : 0x1F01,
VERSION : 0x1F02,
EXTENSIONS : 0x1F03,
//EXTENSIONS : 0x1F03,
NEAREST : 0x2600,
LINEAR : 0x2601,
NEAREST_MIPMAP_NEAREST : 0x2700,
@ -292,11 +290,9 @@ VERTEX_ATTRIB_ARRAY_TYPE : 0x8625,
VERTEX_ATTRIB_ARRAY_NORMALIZED : 0x886A,
VERTEX_ATTRIB_ARRAY_POINTER : 0x8645,
VERTEX_ATTRIB_ARRAY_BUFFER_BINDING : 0x889F,
IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A,
IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B,
//IMPLEMENTATION_COLOR_READ_TYPE : 0x8B9A,
//IMPLEMENTATION_COLOR_READ_FORMAT : 0x8B9B,
COMPILE_STATUS : 0x8B81,
INFO_LOG_LENGTH : 0x8B84,
SHADER_SOURCE_LENGTH : 0x8B88,
SHADER_COMPILER : 0x8DFA,
LOW_FLOAT : 0x8DF0,
MEDIUM_FLOAT : 0x8DF1,
@ -340,8 +336,8 @@ FRAMEBUFFER_BINDING : 0x8CA6,
RENDERBUFFER_BINDING : 0x8CA7,
MAX_RENDERBUFFER_SIZE : 0x84E8,
INVALID_FRAMEBUFFER_OPERATION : 0x0506,
FALSE : 0,
TRUE : 1,
//FALSE : 0,
//TRUE : 1,
UNPACK_FLIP_Y_WEBGL : 0x9240,
UNPACK_PREMULTIPLY_ALPHA_WEBGL : 0x9241
}
@ -364,7 +360,7 @@ Tests.testOES20Constants = function(gl) {
}
}
}
Tests.startUnit = function() {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(canvas.getContext(GL_CONTEXT_ID));

View File

@ -11,16 +11,18 @@ Tests.testGetWebGL = function() {
var canvas = document.getElementById('webgl');
var gl;
assertOk(function(){gl = canvas.getContext(GL_CONTEXT_ID)});
assertFail("Shouldn't be able to get 2D context after getting WebGL context", function(){canvas.getContext('2d')});
assertOk(function(){canvas.getContext(GL_CONTEXT_ID)});
assertEquals("ctx.canvas === canvas", gl.canvas, canvas);
assertOk(function(){g2d = canvas.getContext('2d')});
assert("Should get a null 2d context after getting webgl context", g2d === null);
}
Tests.testGet2D = function() {
var canvas = document.getElementById('2d');
var ctx;
assertOk(function(){ctx = canvas.getContext('2d')});
assertFail("Shouldn't be able to get WebGL context after getting 2D context", function(){canvas.getContext(GL_CONTEXT_ID)});
assertOk(function(){canvas.getContext('2d')});
var g2d;
var gl;
assertOk(function(){g2d = canvas.getContext('2d')});
assertOk(function(){gl = canvas.getContext(GL_CONTEXT_ID)});
assert("Should get a null WebGL context after getting 2D context", gl === null);
}
</script>
<style>canvas{position:absolute;}</style>

View File

@ -98,6 +98,8 @@ var methods = ['canvas',
"getAttribLocation",
"getBufferParameter",
"getError",
"getExtension",
"getSupportedExtensions",
"getFramebufferAttachmentParameter",
"getProgramInfoLog",
"getRenderbufferParameter",
@ -106,6 +108,7 @@ var methods = ['canvas',
"getUniformLocation",
"hint",
"isBuffer",
"isContextLost",
"isEnabled",
"isFramebuffer",
"isProgram",
@ -185,7 +188,7 @@ Tests.testOES20Methods = function(gl) {
}
}
}
Tests.startUnit = function() {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(canvas.getContext(GL_CONTEXT_ID));

View File

@ -21,8 +21,8 @@ Tests.testBufferData = function(gl) {
function(){gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(0), gl.STATIC_DRAW);});
assertFail("bad target",
function(){gl.bufferData(gl.TEXTURE_2D, new Float32Array([1,2,3]), gl.STATIC_DRAW);});
assertFail("array for data",
function(){gl.bufferData(gl.ARRAY_BUFFER, [1,2,3], gl.STATIC_DRAW);});
// assertFail("array for data",
// function(){gl.bufferData(gl.ARRAY_BUFFER, [1,2,3], gl.STATIC_DRAW);});
assertFail("bad usage",
function(){gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1,2,3]), gl.TEXTURE_2D);});
assertOk(function(){gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Float32Array([1,2,3]), gl.STATIC_DRAW);});

View File

@ -14,7 +14,7 @@ Tests.startUnit = function () {
Tests.testDeleteBuffer = function(gl) {
assertThrowNoGLError(gl, "number ", function(){ gl.deleteBuffer(1); });
assertThrowNoGLError(gl, "null", function(){ gl.deleteBuffer(null); });
assertGLError(gl, gl.NO_ERROR, "null", function(){ gl.deleteBuffer(null); });
assertThrowNoGLError(gl, "0", function(){ gl.deleteBuffer(0); });
assertThrowNoGLError(gl, "false", function(){ gl.deleteBuffer(false); });
assertThrowNoGLError(gl, "true", function(){ gl.deleteBuffer(true); });

View File

@ -93,13 +93,13 @@ Tests.testDrawArraysOutOfBounds = function(gl, prog, v,n,t) {
assertGLError(gl, gl.INVALID_VALUE, "negative offset",
function(){gl.drawArrays(gl.TRIANGLES, 0, -1);});
assertGLError(gl, gl.INVALID_OPERATION, "count out of range",
function(){gl.drawArrays(gl.TRIANGLES, 1, 0);});
function(){gl.drawArrays(gl.TRIANGLES, 0, 1);});
assertGLError(gl, gl.INVALID_VALUE, "negative count",
function(){gl.drawArrays(gl.TRIANGLES, -1, 0);});
function(){gl.drawArrays(gl.TRIANGLES, 0, -1);});
assertGLError(gl, gl.INVALID_VALUE, "positive count, negative offset",
function(){gl.drawArrays(gl.TRIANGLES, 1, -1);});
assertGLError(gl, gl.INVALID_VALUE, "negative count, positive offset",
function(){gl.drawArrays(gl.TRIANGLES, -1, 1);});
assertGLError(gl, gl.INVALID_VALUE, "negative count, positive offset",
function(){gl.drawArrays(gl.TRIANGLES, 1, -1);});
gl.deleteBuffer(b);
}
@ -121,13 +121,13 @@ Tests.testDrawArraysWithDataOutOfBounds = function(gl, prog, v,n,t) {
assertGLError(gl, gl.INVALID_VALUE, "negative offset",
function(){gl.drawArrays(gl.TRIANGLES, 0, -1);});
assertGLError(gl, gl.INVALID_OPERATION, "count out of range",
function(){gl.drawArrays(gl.TRIANGLES, 4, 0);});
function(){gl.drawArrays(gl.TRIANGLES, 0, 4);});
assertGLError(gl, gl.INVALID_VALUE, "negative count",
function(){gl.drawArrays(gl.TRIANGLES, -1, 0);});
function(){gl.drawArrays(gl.TRIANGLES, 0, -1);});
assertGLError(gl, gl.INVALID_VALUE, "positive count, negative offset",
function(){gl.drawArrays(gl.TRIANGLES, 2, -1);});
function(){gl.drawArrays(gl.TRIANGLES, -1, 2);});
assertGLError(gl, gl.INVALID_VALUE, "negative count, positive offset",
function(){gl.drawArrays(gl.TRIANGLES, -1, 1);});
function(){gl.drawArrays(gl.TRIANGLES, 1, -1);});
gl.deleteBuffer(b);
}
@ -221,7 +221,7 @@ Tests.testDrawArraysVBOOutOfBounds = function(gl, prog, v,n,t) {
assertGLError(gl, gl.INVALID_OPERATION, "1",
function(){gl.drawArrays(gl.TRIANGLES, 6, 1);});
assertGLError(gl, gl.INVALID_VALUE, "negative count",
function(){gl.drawArrays(gl.TRIANGLES, -1, 2);});
function(){gl.drawArrays(gl.TRIANGLES, 2, -1);});
assertGLError(gl, gl.INVALID_OPERATION, "3",
function(){gl.drawArrays(gl.TRIANGLES, 0, 7);});
assertGLError(gl, gl.INVALID_OPERATION, "4",
@ -240,7 +240,7 @@ Tests.testDrawArraysVBOMultiOutOfBounds = function(gl, prog, v,n,t) {
assertGLError(gl, gl.INVALID_OPERATION, "1",
function(){gl.drawArrays(gl.TRIANGLES, 6, 1);});
assertGLError(gl, gl.INVALID_VALUE, "negative count",
function(){gl.drawArrays(gl.TRIANGLES, -1, 2);});
function(){gl.drawArrays(gl.TRIANGLES, 2, -1);});
assertGLError(gl, gl.INVALID_OPERATION, "2",
function(){gl.drawArrays(gl.TRIANGLES, 0, 7);});
assertGLError(gl, gl.INVALID_OPERATION, "3",

View File

@ -174,19 +174,7 @@ Tests.testSharedBuffers = function(gl, prog, v,n,t) {
var vertsArr = new Uint16Array([0,1,3,3,4,5,6,7,8]);
gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
gl.bufferData(gl.ARRAY_BUFFER, vertsArr, gl.STATIC_DRAW);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo);
gl.enableVertexAttribArray(v);
gl.vertexAttribPointer(v, 3, gl.UNSIGNED_SHORT, false, 0, 0);
assertFail('buffer data is shared between indexes and verts', function() {
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
});
var vertsArr2 = new Uint16Array([2]);
gl.bufferSubData(gl.ARRAY_BUFFER, 4, vertsArr2); // replace the first 3 with a 2
assertOk('buffer data is shared between indexes and verts', function() {
gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0);
});
gl.bindBuffer(gl.ARRAY_BUFFER, null);
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
assertFail(function(){gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, vbo)});
gl.deleteBuffer(vbo);
}

View File

@ -44,9 +44,6 @@ Tests.testReadPixels = function(gl) {
assertOk(function(){gl.readPixels(0,0,1,1,gl.RGBA, gl.UNSIGNED_BYTE, id);});
assertOk(function(){gl.readPixels(0,0,16,16,gl.RGBA, gl.UNSIGNED_BYTE, id);});
assertOk(function(){gl.readPixels(15,15,1,1,gl.RGBA, gl.UNSIGNED_BYTE, id);});
var format = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_FORMAT);
var type = gl.getParameter(gl.IMPLEMENTATION_COLOR_READ_TYPE);
assertOk(function(){gl.readPixels(15,15,1,1, format, type, id);});
}
Tests.testReadPixelsRGBA = function(gl) {
gl.clearColor(1, 0, 1, 0);

View File

@ -91,10 +91,10 @@ Tests.testTexImage2D = function(gl) {
assertGLError(gl, gl.INVALID_OPERATION, "not enough data", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, 1,1,gl.RGBA,gl.UNSIGNED_BYTE, new Uint8Array([0,0,0]));
});
assertGLError(gl, gl.INVALID_VALUE, "format does not match internal format", function(){
assertGLError(gl, gl.INVALID_OPERATION, "format does not match internal format", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, 1,1,gl.RGB,gl.UNSIGNED_BYTE, new Uint8Array([0,0,0]));
});
assertGLError(gl, gl.INVALID_VALUE, "type does not match original", function(){
assertGLError(gl, gl.INVALID_OPERATION, "type does not match original", function(){
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, 1,1,gl.RGBA,gl.UNSIGNED_SHORT_4_4_4_4, new Uint16Array([0]));
});
}

View File

@ -42,25 +42,25 @@ Tests.testTexImage2D = function(gl) {
function() {gl.texSubImage2D(gl.FLOAT, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); });
assertOk("good args",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c); });
assertGLError(gl, gl.INVALID_VALUE, "format not same as original",
assertGLError(gl, gl.INVALID_OPERATION, "format not same as original",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); });
assertGLError(gl, gl.INVALID_VALUE, "type not same as original",
assertGLError(gl, gl.INVALID_OPERATION, "type not same as original",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); });
assertOk("make texture RGB",
function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, c); });
assertOk("format same as original RGB",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); });
assertGLError(gl, gl.INVALID_VALUE, "format not same as original RGB",
assertGLError(gl, gl.INVALID_OPERATION, "format not same as original RGB",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); });
assertGLError(gl, gl.INVALID_VALUE, "type not same as original RGB",
assertGLError(gl, gl.INVALID_OPERATION, "type not same as original RGB",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_SHORT_5_6_5, c); });
assertOk("make texture RGBA 4_4_4_4",
function() {gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); });
assertOk("format same as original RGBA 4_4_4_4",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_SHORT_4_4_4_4, c); });
assertGLError(gl, gl.INVALID_VALUE, "format not same as original RGBA 4_4_4_4",
assertGLError(gl, gl.INVALID_OPERATION, "format not same as original RGBA 4_4_4_4",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGB, gl.UNSIGNED_BYTE, c); });
assertGLError(gl, gl.INVALID_VALUE, "type not same as original RGBA 4_4_4_4",
assertGLError(gl, gl.INVALID_OPERATION, "type not same as original RGBA 4_4_4_4",
function() {gl.texSubImage2D(gl.TEXTURE_2D, 0, 0,0, gl.RGBA, gl.UNSIGNED_BYTE, c); });
}

View File

@ -29,11 +29,11 @@ Tests.testUniformf = function(gl, unwrappedGL) {
function(){gl.uniformMatrix4fv(588939, false, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
assertThrowNoGLError(gl, "bad location (negative)",
function(){gl.uniformMatrix4fv(-588939, false, [1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
assertOk("too many values to 4fv",
assertGLError(gl, gl.INVALID_VALUE, "17 values to 4fv",
function(){gl.uniformMatrix4fv(fm4, false, [0,1,0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
assertOk("too many values to 2fv",
assertGLError(gl, gl.INVALID_VALUE, "5 values to 2fv",
function(){gl.uniformMatrix2fv(fm2, false, [0,2,1, 2,2]);});
assertOk("too many values to 3fv",
assertGLError(gl, gl.INVALID_VALUE, "10 values to 3fv",
function(){gl.uniformMatrix3fv(fm3, false, [0,2,2,2, 2,2,2, 2,1,2]);});
assertGLError(gl, gl.INVALID_VALUE, "too few values to 4fv",
function(){gl.uniformMatrix4fv(fm4, false, [0,0,0, 0,2,0,0, 0,0,3,0, 0,0,0,4]);});
@ -67,10 +67,11 @@ Tests.testUniformf = function(gl, unwrappedGL) {
var loc1Name = 'am' + ii + '[1]';
var loc0 = f.uniform(loc0Name);
var loc1 = f.uniform(loc1Name);
var fname = "uniformMatrix" + ii + "fv";
assert(loc0Name, loc0 != null);
assert(loc1Name, loc1 != null);
assertOk("set array of 2 matrices " + ii + "2fv",
function(){gl.uniformMatrix2fv(loc0, false, all);});
assertOk("set array of 2 matrices " + ii + "fv",
function(){gl[fname].call(gl,loc0, false, all);});
var actual = unwrappedGL.getUniform(sh.shader.program, loc0);
assert("got value for loc0",
gl.NO_ERROR == checkError(gl, "getUniform loc0"));
@ -80,22 +81,14 @@ Tests.testUniformf = function(gl, unwrappedGL) {
gl.NO_ERROR == checkError(gl, "getUniform loc1"));
assertArrayEquals(mats[1], actual);
assertOk("set array of second array of 2 matrixes",
function(){gl.uniformMatrix2fv(loc1, false, mats[0]);});
function(){gl[fname].call(gl, loc1, false, mats[0]);});
var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
assert("got value for loc1",
gl.NO_ERROR == checkError(gl, "getUniform loc1"));
assertArrayEquals(mats[0], actual);
var big = mats[1].concat([3]);
assertOk("set array of first array of 2 matrixes plus 1 value",
function(){gl.uniformMatrix2fv(loc0, false, big);});
var actual = unwrappedGL.getUniform(sh.shader.program, loc0);
assert("got value for loc0",
gl.NO_ERROR == checkError(gl, "getUniform loc0"));
assertArrayEquals(mats[1], actual);
var actual = unwrappedGL.getUniform(sh.shader.program, loc1);
assert("got value for loc1",
gl.NO_ERROR == checkError(gl, "getUniform loc1"));
assertArrayEquals(mats[0], actual);
assertGLError(gl, gl.INVALID_VALUE, "set array of first array of 2 matrixes plus 1 value",
function(){gl[fname].call(gl, loc0, false, big);});
}
});
var d = new Uint8Array(4);
@ -122,7 +115,8 @@ varying vec4 texCoord0;
void main()
{
texCoord0 = vec4(Tex.s, 1.0-Tex.t, fm2[0][1]+fm3[2][1], 0.0);
float d = am2[1][1][1] + am3[1][2][2] + am4[1][3][3];
float d = am2[0][1][1] + am3[0][2][2] + am4[0][3][3] +
am2[1][1][1] + am3[1][2][2] + am4[1][3][3];
gl_Position = vec4(Vertex, 1.0 + d * 0.0001);
}
</script>

View File

@ -0,0 +1,95 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../unit.css" />
<script type="application/x-javascript" src="../unit.js"></script>
<script type="application/x-javascript" src="../util.js"></script>
<script type="application/x-javascript">
Tests.startUnit = function () {
var canvas = document.getElementById('gl');
var gl = wrapGLContext(canvas.getContext(GL_CONTEXT_ID));
return [gl];
}
Tests.testUniformArray = function(gl) {
var sh = new Filter(gl, 'foobar-vert', 'foobar-frag');
sh.apply(function(f){
var uniV4 = f.uniform('uniV4');
var uniFloat = f.uniform('uniFloat');
assertOk("1fv on 1fv",
function(){gl.uniform1fv(uniFloat, [2]);});
assertOk("5 values on 1fv",
function(){gl.uniform1fv(uniFloat, [2,3,4,5,6]);});
assertOk("4fv on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4]);});
assertOk("8 values on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4, 5, 6, 7, 8]);});
var uniformsFound = 0;
var numUniforms = gl.getProgramParameter(f.shader.program, gl.ACTIVE_UNIFORMS);
for (var i = 0; i < numUniforms; ++i) {
var uniformName = gl.getActiveUniform(f.shader.program, i).name;
if (uniformName.indexOf('uniV4') == 0 || uniformName.indexOf('uniFloat') == 0) {
assert("Uniform array of length 1 ends with [0]", uniformName.indexOf("[0]") != -1);
++uniformsFound;
}
}
assert("Both uniforms found", uniformsFound == 2);
uniV4 = f.uniform('uniV4[0]');
uniFloat = f.uniform('uniFloat[0]');
assertOk("1fv on 1fv",
function(){gl.uniform1fv(uniFloat, [2]);});
assertOk("5 values on 1fv",
function(){gl.uniform1fv(uniFloat, [2,3,4,5,6]);});
assertOk("4fv on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4]);});
assertOk("8 values on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4, 5, 6, 7, 8]);});
});
var d = new Uint8Array(4);
gl.readPixels(0,0,1,1,gl.RGBA, gl.UNSIGNED_BYTE, d);
assertArrayEquals([1,2,3,8], d);
sh.destroy();
throwError(gl);
}
Tests.endUnit = function(gl) {
}
</script>
<script id="foobar-vert" type="x-shader/x-vertex">
attribute vec3 Vertex;
attribute vec2 Tex;
uniform float uniFloat[1];
varying vec4 texCoord0;
void main()
{
texCoord0 = vec4(Tex.s, 1.0-Tex.t, uniFloat[0], 0.0);
gl_Position = vec4(Vertex, 1.0);
}
</script>
<script id="foobar-frag" type="x-shader/x-fragment">
#ifdef GL_ES
precision highp float;
#endif
uniform vec4 uniV4[1];
varying vec4 texCoord0;
void main()
{
gl_FragColor = vec4(
uniV4[0].r/256.0,
uniV4[0].g/256.0,
uniV4[0].b/256.0,
uniV4[0].a*texCoord0.z/256.0);
}
</script>
<style>canvas{ position:absolute; }</style>
</head><body>
<canvas id="gl" width="16" height="16"></canvas>
</body></html>

View File

@ -21,15 +21,18 @@ Tests.testUniformf = function(gl) {
function(){gl.uniform4fv(58882929, [1,2,3,4]);});
assertThrowNoGLError(gl, "negative number for location",
function(){gl.uniform4fv(-58882929, [1,2,3,4]);});
assertGLError(gl, gl.INVALID_OPERATION, "??",
function(){gl.uniform1fv(uniV4, [1,2,3,4,5]);});
// for non arrays you must pass in exactly 1 value.
assertGLError(gl, gl.INVALID_OPERATION, "1fv on 4fv",
function(){gl.uniform1fv(uniV4, [1,2,3,4]);});
assertGLError(gl, gl.INVALID_OPERATION, "more than enough values 1fv",
function(){gl.uniform1fv(uniFloat, [2,3,4,5,6]);});
assertGLError(gl, gl.INVALID_OPERATION, "4fv on float",
function(){gl.uniform4fv(uniFloat, [2,3,4,5]);});
assertOk("4fv on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4]);});
assertGLError(gl, gl.INVALID_VALUE, "5 values on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4, 5]);});
assertGLError(gl, gl.INVALID_OPERATION, "8 values on 4fv",
function(){gl.uniform4fv(uniV4, [1, 2, 3, 4, 5, 6, 7, 8]);});
assertGLError(gl, gl.INVALID_OPERATION, "3fv on float",
function(){gl.uniform3fv(uniFloat, [2,3,4]);});
assertGLError(gl, gl.INVALID_OPERATION, "2fv on float",

View File

@ -21,13 +21,16 @@ Tests.testUniformf = function(gl) {
function(){gl.uniform4iv(58882929, [1,2,3,4]);});
assertThrowNoGLError(gl, "negative number as location",
function(){gl.uniform4iv(-58882929, [1,2,3,4]);});
assertOk("more than enough values 4iv",
function(){gl.uniform4iv(uniIV4, [1,2,3,4,5]);});
// For non arrays you must pass in only 1 value.
assertGLError(gl, gl.INVALID_OPERATION, "more than 1 value to 1iv",
function(){gl.uniform1iv(uniInt, [2,3,4,5,6]);});
assertGLError(gl, gl.INVALID_OPERATION, "4iv on int",
function(){gl.uniform4iv(uniInt, [2,3,4,5]);});
assertOk("4iv on 4iv",
function(){gl.uniform4iv(uniIV4, [1, 2, 3, 4]);});
assertGLError(gl, gl.INVALID_VALUE, "5 values on 4iv",
function(){gl.uniform4iv(uniIV4, [1, 2, 3, 4, 5]);});
assertGLError(gl, gl.INVALID_OPERATION, "8 values on 4iv",
function(){gl.uniform4iv(uniIV4, [1, 2, 3, 4, 5, 6, 7, 8]);});
assertGLError(gl, gl.INVALID_OPERATION, "3iv on int",
function(){gl.uniform3iv(uniInt, [2,3,4]);});
assertGLError(gl, gl.INVALID_OPERATION, "2iv on int",

View File

@ -78,10 +78,6 @@ Tests.testVertexAttrib = function(gl, prog, v,n,t) {
function(){gl.vertexAttrib1f(-69092342, 1);});
assertFail("bad index (big positive)",
function(){gl.vertexAttrib1f(58928938, 1);});
assertFail("wrong number of args",
function(){gl.vertexAttrib4f(v, 1,4,5);});
assertFail("wrong number of args, none",
function(){gl.vertexAttrib1f(v);});
assertOk("array too large",
function(){gl.vertexAttrib1fv(v, [1,2,3,4,5]);});
assertFail("array too small",

View File

@ -78,7 +78,10 @@ arr.forEach(function(e){
void main()
{
TexCoord = Tex;
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
gl_Position = vec4(Vertex, x[2]);
}
</script>
@ -91,7 +94,10 @@ arr.forEach(function(e){
void main()
{
TexCoord = Tex;
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
gl_Position = vec4(Vertex, x[4]);
}
</script>
@ -104,7 +110,10 @@ arr.forEach(function(e){
void main()
{
TexCoord = Tex;
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
x[4] = Vertex.z;
gl_Position = vec4(Vertex, x[4]);
}
@ -118,7 +127,10 @@ arr.forEach(function(e){
void main()
{
TexCoord = Tex;
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
int idx = 4 * int(max(1.0, Vertex.x*20.0));
gl_Position = vec4(Vertex, x[idx]);
}
@ -132,7 +144,10 @@ arr.forEach(function(e){
void main()
{
TexCoord = Tex;
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
int idx = 4 * int(max(1.0, Vertex.x*20.0));
x[idx] = Vertex.z;
gl_Position = vec4(Vertex, x[idx]);
@ -161,7 +176,10 @@ precision highp float;
void main()
{
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[2]);
}
</script>
@ -175,7 +193,10 @@ precision highp float;
void main()
{
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[4]);
}
</script>
@ -189,7 +210,10 @@ precision highp float;
void main()
{
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
x[4] = 6.0;
gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[4]);
@ -205,7 +229,10 @@ precision highp float;
void main()
{
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
int idx = 4 * int(max(1.0, TexCoord.x*20.0));
gl_FragColor = vec4(1.0, 0.0, TexCoord.s, x[idx]);
@ -221,7 +248,10 @@ precision highp float;
void main()
{
float x[3] = float[](1.0, 2.0, 3.0);
float x[3];
x[0] = 1.0;
x[1] = 2.0;
x[2] = 3.0;
int idx = 4 * int(max(1.0, TexCoord.x*20.0));
x[idx] = 6.0;

Some files were not shown because too many files have changed in this diff Show More