diff --git a/.travis.yml b/.travis.yml
index 609f618e7a39..1d33074b1e57 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,8 +15,8 @@ script:
- npm run jsHint -- --failTaskOnError
- echo -en 'travis_fold:end:script.jsHint\\r'
- - echo 'test non-webgl' && echo -en 'travis_fold:start:script.test\\r'
- - npm run test -- --exclude WebGL --browsers Electron --failTaskOnError --suppressPassed
+ - echo 'test webgl-stub' && echo -en 'travis_fold:start:script.test\\r'
+ - npm run test -- --browsers Electron --webgl-stub --failTaskOnError --suppressPassed
- echo -en 'travis_fold:end:script.test\\r'
- echo 'makeZipFile' && echo -en 'travis_fold:start:script.makeZipFile\\r'
@@ -30,8 +30,8 @@ script:
- npm run deploy-status -- --status success --message Deployed
- echo -en 'travis_fold:end:script.deploy\\r'
- - echo 'test non-webgl release' && echo -en 'travis_fold:start:script test.release\\r'
- - npm run test -- --exclude WebGL --browsers Electron --failTaskOnError --release --suppressPassed
+ - echo 'test webgl-stub release' && echo -en 'travis_fold:start:script test.release\\r'
+ - npm run test -- --browsers Electron --failTaskOnError --webgl-stub --release --suppressPassed
- echo -en 'travis_fold:end:script test.release\\r'
- echo 'cloc' && echo -en 'travis_fold:start:script.cloc\\r'
diff --git a/Documentation/Contributors/BuildGuide/README.md b/Documentation/Contributors/BuildGuide/README.md
index 0e90d7084438..2a19759ac5b0 100644
--- a/Documentation/Contributors/BuildGuide/README.md
+++ b/Documentation/Contributors/BuildGuide/README.md
@@ -112,10 +112,11 @@ Here's the full set of scripts and what they do.
* **Testing scripts** -- build and run the unit tests
* `test` - Runs all tests with [Karma](http://karma-runner.github.io/0.13/index.html) using the default browser specified in the Karma config file.
* `test-all` - Runs all tests with Karma using all browsers installed on the current system.
- * `test-non-webgl` - Runs only non-WebGL tests with Karma.
- * `test-webgl` - Runs only WebGL tests with Karma.
+ * `test-non-webgl` - Runs only non-WebGL tests.
+ * `test-webgl` - Runs only WebGL tests.
+ * `test-webgl-stub` - Runs all tests using the WebGL stub, which WebGL calls a noop and ignores related test expectations.
* `test-webgl-validation` - Runs all tests with Karma and enables low-level WebGL validation.
- * `test-release` - Runs all tests with Karma on the minified release version of built Cesium.
+ * `test-release` - Runs all tests on the minified release version of built Cesium.
* **Deployment scripts**
* `deploy-s3` - Deploys the built cesium files, the npm package, and the zip file to Amazon S3. This requires having credentials set up for the S3 bucket to which you are deploying.
* `deploy-status` - Set the deployment statuses in GitHub, for use with Travis.
diff --git a/Documentation/Contributors/TestingGuide/README.md b/Documentation/Contributors/TestingGuide/README.md
index cd0bac588d75..f4a7b38d128c 100644
--- a/Documentation/Contributors/TestingGuide/README.md
+++ b/Documentation/Contributors/TestingGuide/README.md
@@ -7,13 +7,15 @@ As of Cesium 1.15, Cesium has over 7,000 tests with 93% code coverage. Cesium h
All new code should have 100% code coverage and should pass all tests. Always run the tests before opening a pull request.
* [Running the Tests](#running-the-tests)
- * [Run All Tests (Run with WebGL Validation)](#run-all-tests-run-with-webgl-validation)
+ * [Run All Tests](#run-all-tests)
+ * [Run with WebGL validation](#run-with-webgl-validation)
+ * [Run with WebGL stub](#run-with-webgl-stub)
* [Select a Test to Run](#select-a-test-to-run)
* [Run Only WebGL Tests](#run-only-webgl-tests)
* [Run Only Non-WebGL Tests](#run-only-non-webgl-tests)
* [Run All Tests against Combined File (Run All Tests against Combined File with Debug Code Removed)]()
* [Run All Tests with Code Coverage (Build 'instrumentForCoverage' First)](#run-all-tests-against-combined-file-run-all-tests-against-combined-file-with-debug-code-removed)
- * [Run All Tests on the Command Line with Karma](#run-all-tests-on-the-command-line-with-karma)
+ * [Running Tests on the Command Line with Karma](#run-all-tests-on-the-command-line-with-karma)
* [Testing Previous Versions of Cesium](#testing-previous-versions-of-cesium)
* [`testfailure` Label for Issues](#testfailure-label-for-issues)
* [Writing Tests](#writing-tests)
@@ -44,7 +46,7 @@ The Cesium tests are written in JavaScript and use [Jasmine](http://jasmine.gith
When running Cesium locally, browse to [http://localhost:8080/](http://localhost:8080/) and there are several test options:
-### Run All Tests (Run with WebGL Validation)
+### Run All Tests
Runs all the tests. As of Cesium 1.15, on a decent laptop, they run in about a minute in Chrome. It is important that the tests run quickly so we run them often.
@@ -62,8 +64,14 @@ In this case, the number of failing tests is listed at the top, and details on e
```
Click on the failed test to rerun just that test. This is useful for saving time when fixing an issue as it avoids rerunning all the tests. Always rerun _all_ the tests before opening a pull request.
+#### Run with WebGL validation
+
The link to **Run with WebGL validation** passes a query parameter to the tests to enable extra low-level WebGL validation such as calling `gl.getError()` after each WebGL call. We use this when doing the monthly Cesium release and when making changes to Cesium's renderer.
+#### Run with WebGL stub
+
+The **Run with WebGL stub** link passes a query parameter to the tests to use Cesium's WebGL stub. This makes all WebGL calls a noop and ignores test expectations that rely on reading back from WebGL. This allows running the tests on CI where a reasonable WebGL implementation is not available and still getting full code coverage albeit not all verification.
+
### Select a Test to Run
This option loads the test page without running any tests.
@@ -140,7 +148,7 @@ It is possible to have 100% code coverage with two tests: one test where `a` and
The number of linearly independent paths (four in this case) is called the **cyclomatic complexity**. Be mindful of this when writing tests. On one extreme, 100% code coverage is the least amount of testing, on the other extreme is covering the cyclomatic complexity, which quickly becomes unreasonable. Use your knowledge of the implementation to devise the best strategy.
-### Run All Tests on the Command Line with Karma
+### Running Tests on the Command Line with Karma
[Karma](http://karma-runner.github.io/0.13/index.html) is a tool which spawns a browser window, runs tests against that browser, and displays the results on the command line.
@@ -166,6 +174,10 @@ It is also possible for Karma to run all tests against each browser installed on
`npm run test-webgl-validation`
+#### Run All Tests with WebGL Stub
+
+`npm run test-webgl-stub`
+
#### Run Only WebGL Tests with Karma
`npm run test-webgl`
@@ -317,7 +329,7 @@ Above, `scene` is scoped at the suite-level, so all tests in the file have acces
```javascript
it('renders', function() {
var p = scene.primitives.add(new DebugModelMatrixPrimitive());
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
```
@@ -331,40 +343,119 @@ The tests in the `'WebGL'` category do not strictly follow this pattern. Creati
Unlike the `Cartesian3` tests we first saw, many tests need to construct the main Cesium `Viewer` widget or one of its major components. Low-level renderer tests construct just `Context` (which, itself, has a canvas and WebGL context), and primitive tests construct a `Scene` (which contains a `Context`).
-As shown above, these tests use Cesium test utility functions: `createViewer`, `createScene`, or `createContext`. These functions honor query parameters passed to the tests (e.g., enabling WebGL validation) and add extra test functions to the returned object.
+As shown above, these tests use Cesium test utility functions: `createViewer`, `createScene`, or `createContext`. These functions honor query parameters passed to the tests (e.g., enabling WebGL validation or the WebGL stub) and add a few utility functions to the returned object. For example, `createScene` creates a 1x1 pixel canvas with a Cesium Scene and adds `renderForSpecs` (to initialize and render a frame) and `destroyForSpecs` to the returned `Scene` object.
-For example, `createScene` creates a 1x1 pixel canvas with a Cesium Scene and adds `renderForSpecs` and `pickForSpecs` to the returned `Scene` object:
+> Most Cesium apps do not render the scene directly; instead, the `Viewer` object's default render loop renders the scene implicit to the user. The tests are an exception; most tests explicitly render the scene.
+
+Cesium adds several custom Jasmine matchers to make the rendering tests more concise and to support running tests with the WebGL stub. When using the WebGL stub, the WebGL implementation is a noop, and test expectations that rely on reading back from WebGL are ignored. The rendering custom matchers are:
+
+* `toRender`
+* `notToRender`
+* `toRenderAndCall`
+* `toPickPrimitive`
+* `notToPick`
+* `toPickAndCall`
+* `toDrillPickAndCall`
+* `toReadPixels`
+* `notToReadPixels`
+* `contextToRender`
+* `notContextToRender`
+
+`toRender` and `notToRender` clear a 1x1 viewport to black, renders the scene into it, and verifies the RGBA value of the pixel, e.g.:
```javascript
it('renders', function() {
var p = scene.primitives.add(new DebugModelMatrixPrimitive());
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render when show is false', function() {
scene.primitives.add(new DebugModelMatrixPrimitive({
show : false
}));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
+```
-it('is picked', function() {
- var p = scene.primitives.add(new DebugModelMatrixPrimitive({
- id : 'id'
- }));
+Like most rendering tests, the first example uses a coarse-grained expectation to check that the pixel is not the default value of black. Although an expectation this coarse-grained may not catch all subtle errors, it is reliable across platforms, and we rarely have bugs a more fine-grained test would have caught, especially with some manual testing (see below).
- var pick = scene.pickForSpecs();
- expect(pick.primitive).toEqual(p);
- expect(pick.id).toEqual('id');
+The second test verifies that the pixel value is the same as the default background color since the primitive's `show` property is `false`.
+
+`toRender` and `notToRender` can also render the scene at a given Cesium simulation time, e.g.,:
+
+```javascript
+expect({
+ scene : scene,
+ time : t
+}).toRender([0, 0, 0, 255]);
+```
+
+For more complicated expectations, which will still be ignored with the WebGL stub, `toRenderAndCall` takes a callback function:
+
+```javascript
+expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[2]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[3]).toEqual(255);
});
```
-In the first test, `renderForSpecs` initializes the frame, renders the scene into the 1x1 canvas, and then returns the RGBA value of the rendered pixel. Like most rendering tests, this uses a coarse-grained expectation to check that the pixel is not the default value of black. Although an expectation this coarse-grained may not catch all subtle errors, it is reliable across platforms, and we rarely have bugs a more fine-grained test would have caught, especially with some manual testing (see below).
-In the second test, `renderForSpecs` is used again, but this time it is to verify that the pixel value is the same as the default background color since the primitive's `show` property is `false`.
+For reliability across WebGL implementations, use complex expectations in `toRenderAndCall` sparingly.
-> Most Cesium apps do not render the scene directly; instead, the `Viewer` object's default render loop renders the scene implicit to the user. The tests are an exception; most tests explicitly render the scene.
+Similar custom matchers are used for picking tests:
+
+```javascript
+var b = billboards.add(/* ... */);
+expect(scene).toPickPrimitive(b); // Can also use toPickAndCall() and toDrillPickAndCall()
+
+b.show = false;
+expect(scene).notToPick();
+```
+
+For tests that render the scene themselves, `toReadPixels` and `notToReadPixels` are used to verify the RGBA value. In the simplest case, pass an RGBA array, e.g.:
+
+```javascript
+expect(context).toReadPixels([0, 0, 0, 255]);
+
+expect(context).notToReadPixels([0, 0, 0, 255]);
+```
+
+`toReadPixels` can also read from a given framebuffer and use an epsilon for the RGBA comparison test, e.g.:
+
+```javascript
+expect({
+ context : context,
+ framebuffer : framebuffer,
+ epsilon : 1
+}).toReadPixels([0, 0, 0, 255]);
+```
+
+Low-level Cesium renderer tests use just a `Context` without a Cesium `Scene`, and use the `contextToRender` and `notContextToRender` custom matchers to render a WebGL point primitive to the context's 1x1 viewport and verify the RGBA value, e.g.:
-In the final test, `pickForSpecs` executes a `Scene.pick` for the one-pixel canvas. A typical follow-up expectation verifies that the primitive of interest was picked and its `id` is the expected value.
+```javascript
+expect({
+ context : context,
+ shaderProgram : sp,
+}).contextToRender(expected);
+
+expect(/* ... */).notContextToRender();
+```
+
+Uniforms, the model matrix, and various depth options can be provided. In addition, instead of providing a full shader program, just the fragment shader's source can be provided, e.g.,
+
+```javascript
+it('can declare automatic uniforms', function() {
+ var fs =
+ 'void main() { ' +
+ ' gl_FragColor = vec4((czm_viewport.x == 0.0) && (czm_viewport.y == 0.0) && (czm_viewport.z == 1.0) && (czm_viewport.w == 1.0)); ' +
+ '}';
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
+});
+```
### GLSL
diff --git a/Source/Core/WebGLConstants.js b/Source/Core/WebGLConstants.js
index 7d053d8275be..56ab401396ad 100644
--- a/Source/Core/WebGLConstants.js
+++ b/Source/Core/WebGLConstants.js
@@ -589,7 +589,10 @@ define([
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC : 0x9279,
TEXTURE_IMMUTABLE_FORMAT : 0x912F,
MAX_ELEMENT_INDEX : 0x8D6B,
- TEXTURE_IMMUTABLE_LEVELS : 0x82DF
+ TEXTURE_IMMUTABLE_LEVELS : 0x82DF,
+
+ // Extensions
+ MAX_TEXTURE_MAX_ANISOTROPY_EXT : 0x84FF
};
return freezeObject(WebGLConstants);
diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js
index 20aa9ded0b77..5af98c8ef63a 100644
--- a/Source/Renderer/Context.js
+++ b/Source/Renderer/Context.js
@@ -109,29 +109,29 @@ define([
}
}
- function makeGetterSetter(gl, propertyName, logFunc) {
+ function makeGetterSetter(gl, propertyName, logFunction) {
return {
get : function() {
var value = gl[propertyName];
- logFunc(gl, 'get: ' + propertyName, value);
+ logFunction(gl, 'get: ' + propertyName, value);
return gl[propertyName];
},
set : function(value) {
gl[propertyName] = value;
- logFunc(gl, 'set: ' + propertyName, value);
+ logFunction(gl, 'set: ' + propertyName, value);
}
};
}
- function wrapGL(gl, logFunc) {
- if (!logFunc) {
+ function wrapGL(gl, logFunction) {
+ if (!defined(logFunction)) {
return gl;
}
function wrapFunction(property) {
return function() {
var result = property.apply(gl, arguments);
- logFunc(gl, property, arguments);
+ logFunction(gl, property, arguments);
return result;
};
}
@@ -143,14 +143,14 @@ define([
// JSLint normally demands that a for..in loop must directly contain an if,
// but in our loop below, we actually intend to iterate all properties, including
// those in the prototype.
- for ( var propertyName in gl) {
+ for (var propertyName in gl) {
var property = gl[propertyName];
// wrap any functions we encounter, otherwise just copy the property to the wrapper.
- if (typeof property === 'function') {
+ if (property instanceof Function) {
glWrapper[propertyName] = wrapFunction(property);
} else {
- Object.defineProperty(glWrapper, propertyName, makeGetterSetter(gl, propertyName, logFunc));
+ Object.defineProperty(glWrapper, propertyName, makeGetterSetter(gl, propertyName, logFunction));
}
}
@@ -196,24 +196,32 @@ define([
webglOptions.stencil = defaultValue(webglOptions.stencil, true); // WebGL default is false
var defaultToWebgl2 = false;
- var webgl2Supported = (typeof WebGL2RenderingContext !== 'undefined');
+ var requestWebgl2 = defaultToWebgl2 && (typeof WebGL2RenderingContext !== 'undefined');
var webgl2 = false;
+
var glContext;
+ var getWebGLStub = options.getWebGLStub;
- if (defaultToWebgl2 && webgl2Supported) {
- glContext = canvas.getContext('webgl2', webglOptions) || canvas.getContext('experimental-webgl2', webglOptions) || undefined;
- if (defined(glContext)) {
- webgl2 = true;
+ if (!defined(getWebGLStub)) {
+ if (requestWebgl2) {
+ glContext = canvas.getContext('webgl2', webglOptions) || canvas.getContext('experimental-webgl2', webglOptions) || undefined;
+ if (defined(glContext)) {
+ webgl2 = true;
+ }
}
- }
- if (!defined(glContext)) {
- glContext = canvas.getContext('webgl', webglOptions) || canvas.getContext('experimental-webgl', webglOptions) || undefined;
- }
- if (!defined(glContext)) {
- throw new RuntimeError('The browser supports WebGL, but initialization failed.');
+ if (!defined(glContext)) {
+ glContext = canvas.getContext('webgl', webglOptions) || canvas.getContext('experimental-webgl', webglOptions) || undefined;
+ }
+ if (!defined(glContext)) {
+ throw new RuntimeError('The browser supports WebGL, but initialization failed.');
+ }
+ } else {
+ // Use WebGL stub when requested for unit tests
+ glContext = getWebGLStub(canvas, webglOptions);
}
this._originalGLContext = glContext;
+ this._gl = glContext;
this._webgl2 = webgl2;
this._id = createGuid();
@@ -226,13 +234,8 @@ define([
this._shaderCache = new ShaderCache(this);
- var gl = this._gl = this._originalGLContext;
+ var gl = glContext;
- this._redBits = gl.getParameter(gl.RED_BITS);
- this._greenBits = gl.getParameter(gl.GREEN_BITS);
- this._blueBits = gl.getParameter(gl.BLUE_BITS);
- this._alphaBits = gl.getParameter(gl.ALPHA_BITS);
- this._depthBits = gl.getParameter(gl.DEPTH_BITS);
this._stencilBits = gl.getParameter(gl.STENCIL_BITS);
ContextLimits._maximumCombinedTextureImageUnits = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS); // min: 8
@@ -341,10 +344,9 @@ define([
ContextLimits._maximumDrawBuffers = this.drawBuffers ? gl.getParameter(WebGLConstants.MAX_DRAW_BUFFERS) : 1;
ContextLimits._maximumColorAttachments = this.drawBuffers ? gl.getParameter(WebGLConstants.MAX_COLOR_ATTACHMENTS) : 1;
- var cc = gl.getParameter(gl.COLOR_CLEAR_VALUE);
- this._clearColor = new Color(cc[0], cc[1], cc[2], cc[3]);
- this._clearDepth = gl.getParameter(gl.DEPTH_CLEAR_VALUE);
- this._clearStencil = gl.getParameter(gl.STENCIL_CLEAR_VALUE);
+ this._clearColor = new Color(0.0, 0.0, 0.0, 0.0);
+ this._clearDepth = 1.0;
+ this._clearStencil = 0;
var us = new UniformState();
var ps = new PassState(this);
@@ -399,7 +401,6 @@ define([
*/
this.cache = {};
-
RenderState.apply(gl, rs, ps);
}
@@ -432,70 +433,6 @@ define([
}
},
- /**
- * The number of red bits per component in the default framebuffer's color buffer. The minimum is eight.
- * @memberof Context.prototype
- * @type {Number}
- * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with RED_BITS
.
- */
- redBits : {
- get : function() {
- return this._redBits;
- }
- },
-
- /**
- * The number of green bits per component in the default framebuffer's color buffer. The minimum is eight.
- * @memberof Context.prototype
- * @type {Number}
- * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with GREEN_BITS
.
- */
- greenBits : {
- get : function() {
- return this._greenBits;
- }
- },
-
- /**
- * The number of blue bits per component in the default framebuffer's color buffer. The minimum is eight.
- * @memberof Context.prototype
- * @type {Number}
- * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with BLUE_BITS
.
- */
- blueBits : {
- get : function() {
- return this._blueBits;
- }
- },
-
- /**
- * The number of alpha bits per component in the default framebuffer's color buffer. The minimum is eight.
- *
- * The alpha channel is used for GL destination alpha operations and by the HTML compositor to combine the color buffer
- * with the rest of the page.
- * @memberof Context.prototype
- * @type {Number}
- * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with ALPHA_BITS
.
- */
- alphaBits : {
- get : function() {
- return this._alphaBits;
- }
- },
-
- /**
- * The number of depth bits per pixel in the default bound framebuffer. The minimum is 16 bits; most
- * implementations will have 24 bits.
- * @memberof Context.prototype
- * @type {Number}
- * @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with DEPTH_BITS
.
- */
- depthBits : {
- get : function() {
- return this._depthBits;
- }
- },
-
/**
* The number of stencil bits per pixel in the default bound framebuffer. The minimum is eight bits.
* @memberof Context.prototype
@@ -663,7 +600,7 @@ define([
},
set : function(value) {
this._throwOnWebGLError = value;
- this._gl = wrapGL(this._originalGLContext, value ? throwOnError : null);
+ this._gl = wrapGL(this._originalGLContext, value ? throwOnError : undefined);
}
},
diff --git a/Specs/Core/writeTextToCanvasSpec.js b/Specs/Core/writeTextToCanvasSpec.js
index 8d7afe453c2e..e170c80d0fe4 100644
--- a/Specs/Core/writeTextToCanvasSpec.js
+++ b/Specs/Core/writeTextToCanvasSpec.js
@@ -83,7 +83,8 @@ defineSuite([
// canvas1 is filled, completely by the I on the left
// and then has empty space on the right, so there
// should only be one "edge": fill -> outside
- expect(getColorChangeCount(canvas1)).toEqual(1);
+ var count = getColorChangeCount(canvas1);
+ expect(count === 1 || count === 2).toEqual(true);
var canvas2 = writeTextToCanvas('I', {
font : '90px "Open Sans"',
@@ -93,7 +94,8 @@ defineSuite([
});
// canvas2 is stroked, so there should be three "edges": outline -> inside -> outline -> outside
- expect(getColorChangeCount(canvas2)).toEqual(3);
+ count = getColorChangeCount(canvas2);
+ expect(count === 3 || count === 4).toEqual(true);
});
it('background color defaults to transparent', function() {
diff --git a/Specs/DataSources/CorridorGeometryUpdaterSpec.js b/Specs/DataSources/CorridorGeometryUpdaterSpec.js
index 528ea91386ec..18bea1bc505c 100644
--- a/Specs/DataSources/CorridorGeometryUpdaterSpec.js
+++ b/Specs/DataSources/CorridorGeometryUpdaterSpec.js
@@ -248,7 +248,7 @@ defineSuite([
var color = new SampledProperty(Color);
color.addSample(time, Color.WHITE);
entity.corridor.material = new ColorMaterialProperty(color);
- expect(updater.isDynamic).toBe(true);
+ expect(updater.isDynamic).toBe(groundPrimitiveSupported);
});
function validateGeometryInstance(options) {
diff --git a/Specs/DataSources/EllipseGeometryUpdaterSpec.js b/Specs/DataSources/EllipseGeometryUpdaterSpec.js
index 29946057615d..3589b7da5dde 100644
--- a/Specs/DataSources/EllipseGeometryUpdaterSpec.js
+++ b/Specs/DataSources/EllipseGeometryUpdaterSpec.js
@@ -274,7 +274,7 @@ defineSuite([
var color = new SampledProperty(Color);
color.addSample(time, Color.WHITE);
entity.ellipse.material = new ColorMaterialProperty(color);
- expect(updater.isDynamic).toBe(true);
+ expect(updater.isDynamic).toBe(groundPrimitiveSupported);
});
function validateGeometryInstance(options) {
diff --git a/Specs/DataSources/PolygonGeometryUpdaterSpec.js b/Specs/DataSources/PolygonGeometryUpdaterSpec.js
index 4874434e2154..d96633dcba8f 100644
--- a/Specs/DataSources/PolygonGeometryUpdaterSpec.js
+++ b/Specs/DataSources/PolygonGeometryUpdaterSpec.js
@@ -259,7 +259,7 @@ defineSuite([
var color = new SampledProperty(Color);
color.addSample(time, Color.WHITE);
entity.polygon.material = new ColorMaterialProperty(color);
- expect(updater.isDynamic).toBe(true);
+ expect(updater.isDynamic).toBe(groundPrimitiveSupported);
});
function validateGeometryInstance(options) {
diff --git a/Specs/DataSources/RectangleGeometryUpdaterSpec.js b/Specs/DataSources/RectangleGeometryUpdaterSpec.js
index 1ccc8b2434a1..998e9ff1d1fe 100644
--- a/Specs/DataSources/RectangleGeometryUpdaterSpec.js
+++ b/Specs/DataSources/RectangleGeometryUpdaterSpec.js
@@ -245,7 +245,7 @@ defineSuite([
var color = new SampledProperty(Color);
color.addSample(time, Color.WHITE);
entity.rectangle.material = new ColorMaterialProperty(color);
- expect(updater.isDynamic).toBe(true);
+ expect(updater.isDynamic).toBe(groundPrimitiveSupported);
});
function validateGeometryInstance(options) {
diff --git a/Specs/Renderer/AutomaticUniformSpec.js b/Specs/Renderer/AutomaticUniformSpec.js
index d5f61229fefd..c0398499b01b 100644
--- a/Specs/Renderer/AutomaticUniformSpec.js
+++ b/Specs/Renderer/AutomaticUniformSpec.js
@@ -68,7 +68,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4((czm_viewport.x == 0.0) && (czm_viewport.y == 0.0) && (czm_viewport.z == 1.0) && (czm_viewport.w == 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewport', function() {
@@ -76,7 +79,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4((czm_viewport.x == 0.0) && (czm_viewport.y == 0.0) && (czm_viewport.z == 1.0) && (czm_viewport.w == 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewportOrthographic', function() {
@@ -88,7 +94,10 @@ defineSuite([
' bool b3 = (czm_viewportOrthographic[0][3] == 0.0) && (czm_viewportOrthographic[1][3] == 0.0) && (czm_viewportOrthographic[2][3] == 0.0) && (czm_viewportOrthographic[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewportTransformation', function() {
@@ -100,7 +109,10 @@ defineSuite([
' bool b3 = (czm_viewportTransformation[0][3] == 0.0) && (czm_viewportTransformation[1][3] == 0.0) && (czm_viewportTransformation[2][3] == 0.0) && (czm_viewportTransformation[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_globeDepthTexture', function() {
@@ -116,7 +128,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(texture2D(czm_globeDepthTexture, vec2(0.5, 0.5)).r == 1.0);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_model', function() {
@@ -128,10 +143,16 @@ defineSuite([
' bool b3 = (czm_model[0][3] == 13.0) && (czm_model[1][3] == 14.0) && (czm_model[2][3] == 15.0) && (czm_model[3][3] == 16.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4( 1.0, 2.0, 3.0, 4.0,
+ var m = new Matrix4(
+ 1.0, 2.0, 3.0, 4.0,
5.0, 6.0, 7.0, 8.0,
9.0, 10.0, 11.0, 12.0,
- 13.0, 14.0, 15.0, 16.0));
+ 13.0, 14.0, 15.0, 16.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseModel', function() {
@@ -143,11 +164,16 @@ defineSuite([
' bool b3 = (czm_inverseModel[0][3] == 0.0) && (czm_inverseModel[1][3] == 0.0) && (czm_inverseModel[2][3] == 0.0) && (czm_inverseModel[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
+ var m = new Matrix4(
0.0, -1.0, 0.0, 1.0,
1.0, 0.0, 0.0, 2.0,
0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_view', function() {
@@ -167,7 +193,10 @@ defineSuite([
' bool b3 = (czm_view[0][3] == 13.0) && (czm_view[1][3] == 14.0) && (czm_view[2][3] == 15.0) && (czm_view[3][3] == 16.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_view3D', function() {
@@ -187,7 +216,10 @@ defineSuite([
' bool b3 = (czm_view3D[0][3] == 13.0) && (czm_view3D[1][3] == 14.0) && (czm_view3D[2][3] == 15.0) && (czm_view3D[3][3] == 16.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewRotation', function() {
@@ -206,7 +238,10 @@ defineSuite([
' bool b2 = (czm_viewRotation[0][2] == 9.0) && (czm_viewRotation[1][2] == 10.0) && (czm_viewRotation[2][2] == 11.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewRotation3D', function() {
@@ -225,7 +260,10 @@ defineSuite([
' bool b2 = (czm_viewRotation3D[0][2] == 9.0) && (czm_viewRotation3D[1][2] == 10.0) && (czm_viewRotation3D[2][2] == 11.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseView', function() {
@@ -245,7 +283,10 @@ defineSuite([
' (czm_inverseView[0][2] == 0.0) && (czm_inverseView[1][2] == 0.0) && (czm_inverseView[2][2] == 1.0) && (czm_inverseView[3][2] == 0.0)' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseView3D', function() {
@@ -265,7 +306,10 @@ defineSuite([
' (czm_inverseView3D[0][2] == 0.0) && (czm_inverseView3D[1][2] == 0.0) && (czm_inverseView3D[2][2] == 1.0) && (czm_inverseView3D[3][2] == 0.0)' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseViewRotation', function() {
@@ -285,7 +329,10 @@ defineSuite([
' (czm_inverseViewRotation[0][2] == 0.0) && (czm_inverseViewRotation[1][2] == 0.0) && (czm_inverseViewRotation[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseViewRotation3D', function() {
@@ -305,7 +352,10 @@ defineSuite([
' (czm_inverseViewRotation3D[0][2] == 0.0) && (czm_inverseViewRotation3D[1][2] == 0.0) && (czm_inverseViewRotation3D[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_projection', function() {
@@ -326,7 +376,10 @@ defineSuite([
' bool b3 = (czm_projection[0][3] == 13.0) && (czm_projection[1][3] == 14.0) && (czm_projection[2][3] == 15.0) && (czm_projection[3][3] == 16.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseProjection', function() {
@@ -347,7 +400,10 @@ defineSuite([
' bool b3 = (czm_inverseProjection[0][3] == 0.0) && (czm_inverseProjection[1][3] == 0.0) && (czm_inverseProjection[2][3] == 0.0) && (czm_inverseProjection[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseProjectionOIT', function() {
@@ -368,7 +424,10 @@ defineSuite([
' bool b3 = (czm_inverseProjectionOIT[0][3] == 0.0) && (czm_inverseProjectionOIT[1][3] == 0.0) && (czm_inverseProjectionOIT[2][3] == 0.0) && (czm_inverseProjectionOIT[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseProjectionOIT in 2D', function() {
@@ -391,7 +450,10 @@ defineSuite([
' bool b3 = (czm_inverseProjectionOIT[0][3] == 0.0) && (czm_inverseProjectionOIT[1][3] == 0.0) && (czm_inverseProjectionOIT[2][3] == 0.0) && (czm_inverseProjectionOIT[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_infiniteProjection', function() {
@@ -410,7 +472,10 @@ defineSuite([
' bool b3 = (czm_infiniteProjection[0][3] == 13.0) && (czm_infiniteProjection[1][3] == 14.0) && (czm_infiniteProjection[2][3] == 15.0) && (czm_infiniteProjection[3][3] == 16.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_modelView', function() {
@@ -430,11 +495,16 @@ defineSuite([
' bool b3 = (czm_modelView[0][3] == 0.0) && (czm_modelView[1][3] == 0.0) && (czm_modelView[2][3] == 0.0) && (czm_modelView[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
+ var m = new Matrix4(
2.0, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_modelView3D', function() {
@@ -454,11 +524,16 @@ defineSuite([
' bool b3 = (czm_modelView3D[0][3] == 0.0) && (czm_modelView3D[1][3] == 0.0) && (czm_modelView3D[2][3] == 0.0) && (czm_modelView3D[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
+ var m = new Matrix4(
2.0, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_modelViewRelativeToEye', function() {
@@ -478,11 +553,16 @@ defineSuite([
' bool b3 = (czm_modelViewRelativeToEye[0][3] == 0.0) && (czm_modelViewRelativeToEye[1][3] == 0.0) && (czm_modelViewRelativeToEye[2][3] == 0.0) && (czm_modelViewRelativeToEye[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
+ var m = new Matrix4(
2.0, 0.0, 0.0, 0.0,
0.0, 2.0, 0.0, 0.0,
0.0, 0.0, 2.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseModelView', function() {
@@ -497,11 +577,16 @@ defineSuite([
' bool b3 = (czm_inverseModelView[0][3] == 0.0) && (czm_inverseModelView[1][3] == 0.0) && (czm_inverseModelView[2][3] == 0.0) && (czm_inverseModelView[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 0.0, -1.0, 0.0, 1.0,
- 1.0, 0.0, 0.0, 2.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 0.0, -1.0, 0.0, 1.0,
+ 1.0, 0.0, 0.0, 2.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseModelView3D', function() {
@@ -516,11 +601,16 @@ defineSuite([
' bool b3 = (czm_inverseModelView3D[0][3] == 0.0) && (czm_inverseModelView3D[1][3] == 0.0) && (czm_inverseModelView3D[2][3] == 0.0) && (czm_inverseModelView3D[3][3] == 1.0); ' +
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 0.0, -1.0, 0.0, 1.0,
- 1.0, 0.0, 0.0, 2.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 0.0, -1.0, 0.0, 1.0,
+ 1.0, 0.0, 0.0, 2.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_viewProjection', function() {
@@ -544,7 +634,10 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_inverseViewProjection', function() {
@@ -568,7 +661,10 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_modelViewProjection', function() {
@@ -592,11 +688,16 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseModelViewProjection', function() {
@@ -620,11 +721,16 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_modelViewProjectionRelativeToEye', function() {
@@ -648,11 +754,16 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_modelViewInfiniteProjection', function() {
@@ -677,11 +788,16 @@ defineSuite([
' gl_FragColor = vec4(b0 && b1 && b2 && b3); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_normal', function() {
@@ -693,11 +809,16 @@ defineSuite([
' (czm_normal[0][2] == 0.0) && (czm_normal[1][2] == 0.0) && (czm_normal[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 8.0,
- 0.0, 0.0, 1.0, 9.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 8.0,
+ 0.0, 0.0, 1.0, 9.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseNormal', function() {
@@ -709,11 +830,16 @@ defineSuite([
' (czm_inverseNormal[0][2] == 0.0) && (czm_inverseNormal[1][2] == 0.0) && (czm_inverseNormal[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 0.0, -1.0, 0.0, 7.0,
- 1.0, 0.0, 0.0, 8.0,
- 0.0, 0.0, 1.0, 9.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 0.0, -1.0, 0.0, 7.0,
+ 1.0, 0.0, 0.0, 8.0,
+ 0.0, 0.0, 1.0, 9.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_normal3D', function() {
@@ -725,11 +851,16 @@ defineSuite([
' (czm_normal3D[0][2] == 0.0) && (czm_normal3D[1][2] == 0.0) && (czm_normal3D[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 1.0, 0.0, 0.0, 7.0,
- 0.0, 1.0, 0.0, 8.0,
- 0.0, 0.0, 1.0, 9.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 1.0, 0.0, 0.0, 7.0,
+ 0.0, 1.0, 0.0, 8.0,
+ 0.0, 0.0, 1.0, 9.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_inverseNormal3D', function() {
@@ -741,11 +872,16 @@ defineSuite([
' (czm_inverseNormal3D[0][2] == 0.0) && (czm_inverseNormal3D[1][2] == 0.0) && (czm_inverseNormal3D[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, undefined, new Matrix4(
- 0.0, -1.0, 0.0, 7.0,
- 1.0, 0.0, 0.0, 8.0,
- 0.0, 0.0, 1.0, 9.0,
- 0.0, 0.0, 0.0, 1.0));
+ var m = new Matrix4(
+ 0.0, -1.0, 0.0, 7.0,
+ 1.0, 0.0, 0.0, 8.0,
+ 0.0, 0.0, 1.0, 9.0,
+ 0.0, 0.0, 0.0, 1.0);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ modelMatrix : m
+ }).contextToRender();
});
it('has czm_encodedCameraPositionMCHigh and czm_encodedCameraPositionMCLow', function() {
@@ -758,7 +894,10 @@ defineSuite([
' gl_FragColor = vec4(b); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_entireFrustum', function() {
@@ -766,7 +905,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4((czm_entireFrustum.x == 1.0) && (czm_entireFrustum.y == 1000.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_frustumPlanes', function() {
@@ -774,7 +916,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(equal(czm_frustumPlanes, vec4(2.0, -2.0, -1.0, 1.0))); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sunPositionWC', function() {
@@ -782,7 +927,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_sunPositionWC != vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sunPositionColumbusView', function() {
@@ -790,7 +938,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_sunPositionColumbusView != vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sunDirectionEC', function() {
@@ -798,7 +949,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_sunDirectionEC != vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sunDirectionWC', function() {
@@ -806,7 +960,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_sunDirectionWC != vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_moonDirectionEC', function() {
@@ -814,7 +971,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_moonDirectionEC != vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_viewerPositionWC', function() {
@@ -822,7 +982,10 @@ defineSuite([
us.update(createFrameState(context, createMockCamera()));
var fs = 'void main() { gl_FragColor = vec4(czm_viewerPositionWC == vec3(0.0)); }';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_frameNumber', function() {
@@ -830,7 +993,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_frameNumber != 0.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_morphTime', function() {
@@ -838,7 +1004,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_morphTime == 1.0); ' + // 3D
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_temeToPseudoFixed', function() {
@@ -853,7 +1022,10 @@ defineSuite([
' (czm_temeToPseudoFixed[0][2] == 0.0) && (czm_temeToPseudoFixed[1][2] == 0.0) && (czm_temeToPseudoFixed[2][2] == 1.0) ' +
' ); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passEnvironment', function() {
@@ -864,7 +1036,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passEnvironment);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passCompute', function() {
@@ -875,7 +1050,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passCompute);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passGlobe', function() {
@@ -886,7 +1064,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passGlobe);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passGround', function() {
@@ -897,7 +1078,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passGround);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passOpaque', function() {
@@ -908,7 +1092,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passOpaque);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passTranslucent', function() {
@@ -919,7 +1106,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passTranslucent);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_pass and czm_passOverlay', function() {
@@ -930,7 +1120,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pass == czm_passOverlay);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sceneMode', function() {
@@ -938,7 +1131,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_sceneMode == 3.0); ' + // 3D
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sceneMode2D', function() {
@@ -946,7 +1142,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_sceneMode2D == 2.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sceneModeColumbusView', function() {
@@ -954,7 +1153,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_sceneModeColumbusView == 1.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sceneMode3D', function() {
@@ -962,7 +1164,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_sceneMode3D == 3.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_sceneModeMorphing', function() {
@@ -970,7 +1175,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_sceneModeMorphing == 0.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_eyeHeight2D == 0,0 in Scene3D', function() {
@@ -978,7 +1186,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_eyeHeight2D.x == 0.0, czm_eyeHeight2D.y == 0.0, 1.0, 1.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_eyeHeight2D in Scene2D', function() {
@@ -1000,7 +1211,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_eyeHeight2D.x == 2.0, czm_eyeHeight2D.y == 4.0, 1.0, 1.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_imagerySplitPosition', function() {
@@ -1008,7 +1222,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_imagerySplitPosition == 0.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
}, 'WebGL');
diff --git a/Specs/Renderer/BuiltinFunctionsSpec.js b/Specs/Renderer/BuiltinFunctionsSpec.js
index 323f97006725..4b8436748698 100644
--- a/Specs/Renderer/BuiltinFunctionsSpec.js
+++ b/Specs/Renderer/BuiltinFunctionsSpec.js
@@ -33,7 +33,10 @@ defineSuite([
' gl_FragColor = vec4(czm_transpose(m) == mt); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_transpose (3x3)', function() {
@@ -44,7 +47,10 @@ defineSuite([
' gl_FragColor = vec4(czm_transpose(m) == mt); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_transpose (4x4)', function() {
@@ -55,7 +61,10 @@ defineSuite([
' gl_FragColor = vec4(czm_transpose(m) == mt); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_eyeToWindowCoordinates', function() {
@@ -81,7 +90,10 @@ defineSuite([
' gl_FragColor = vec4(all(lessThan(diff, vec2(czm_epsilon6))));' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_windowToEyeCoordinates', function() {
@@ -107,7 +119,10 @@ defineSuite([
' gl_FragColor = vec4(all(lessThan(diff, vec3(czm_epsilon6))));' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_tangentToEyeSpaceMatrix', function() {
@@ -120,7 +135,10 @@ defineSuite([
' mat3 actual = czm_tangentToEyeSpaceMatrix(normal, tangent, bitangent); ' +
' gl_FragColor = vec4(actual == expected); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_translateRelativeToEye', function() {
@@ -149,7 +167,11 @@ defineSuite([
' gl_FragColor = vec4(p == vec4(5.0, 3.0, 1.0, 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('has czm_antialias', function() {
@@ -160,7 +182,10 @@ defineSuite([
' vec4 result = czm_antialias(color0, color1, color1, 0.5);' +
' gl_FragColor = vec4(result == color1);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('czm_pointAlongRay: point at ray origin', function() {
@@ -168,7 +193,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pointAlongRay(czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)), 0.0) == vec3(0.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('czm_pointAlongRay: point in front of ray origin', function() {
@@ -176,7 +204,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pointAlongRay(czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)), 2.0) == vec3(2.0, 0.0, 0.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('czm_pointAlongRay: point behind ray origin', function() {
@@ -184,7 +215,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_pointAlongRay(czm_ray(vec3(0.0), vec3(0.0, 1.0, 0.0)), -2.0) == vec3(0.0, -2.0, 0.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_octDecode(vec2)', function() {
@@ -192,7 +226,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(all(lessThanEqual(abs(czm_octDecode(vec2(128.0, 128.0)) - vec3(0.0, 0.0, 1.0)), vec3(0.01)))); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_octDecode(float)', function() {
@@ -200,7 +237,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(all(lessThanEqual(abs(czm_octDecode(32896.0) - vec3(0.0, 0.0, 1.0)), vec3(0.01)))); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_octDecode(vec2, vec3, vec3, vec3)', function() {
@@ -213,7 +253,10 @@ defineSuite([
' decoded = decoded && all(lessThanEqual(abs(c - vec3(0.0, 0.0, 1.0)), vec3(0.01)));' +
' gl_FragColor = vec4(decoded);' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_decompressTextureCoordinates', function() {
@@ -221,7 +264,10 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(czm_decompressTextureCoordinates(8386559.0) == vec2(0.4998779, 0.4998779)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has signNotZero : float', function() {
@@ -231,7 +277,10 @@ defineSuite([
' czm_signNotZero(5.0) == 1.0, ' +
' czm_signNotZero(-5.0) == -1.0, 1.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has signNotZero : vec2', function() {
@@ -242,7 +291,10 @@ defineSuite([
' czm_signNotZero(vec2(-1.0, -1.0)) == vec2(-1.0, -1.0), ' +
' czm_signNotZero(vec2(-1.0, 0.0)) == vec2(-1.0, 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has signNotZero : vec3', function() {
@@ -253,7 +305,10 @@ defineSuite([
' czm_signNotZero(vec3(-1.0, -1.0, -1.0)) == vec3(-1.0, -1.0, -1.0), ' +
' czm_signNotZero(vec3(-1.0, 0.0, 1.0)) == vec3(-1.0, 1.0, 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has signNotZero : vec4', function() {
@@ -264,7 +319,10 @@ defineSuite([
' czm_signNotZero(vec4(-1.0, -1.0, -1.0, -1.0)) == vec4(-1.0), ' +
' czm_signNotZero(vec4(-1.0, 0.0, 1.0, -10.0)) == vec4(-1.0, 1.0, 1.0, -1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_cosineAndSine in all 4 quadrants', function() {
@@ -278,7 +336,10 @@ defineSuite([
' isBounded(czm_cosineAndSine(-czm_piOverFour).x, 0.707106, 0.707107) && isBounded(czm_cosineAndSine(-czm_piOverFour).y, -0.707107, -0.707106), ' +
' isBounded(czm_cosineAndSine(-czm_pi + czm_piOverFour).x, -0.707107, -0.707106) && isBounded(czm_cosineAndSine(-czm_pi + czm_piOverFour).y, -0.707107, -0.707106)); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('can calculate nearFarScalar', function() {
@@ -290,7 +351,10 @@ defineSuite([
' czm_nearFarScalar(testNearFarScalar, 20.0 * 20.0) == 0.0, ' +
' czm_nearFarScalar(testNearFarScalar, 50.0 * 50.0) == 0.0); ' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has czm_cascadeColor', function() {
@@ -298,6 +362,9 @@ defineSuite([
'void main() { ' +
' gl_FragColor = vec4(all(equal(czm_cascadeColor(vec4(0.5)), vec4(1.0, 0.5, 1.0, 2.0))));' +
'}';
- context.verifyDrawForSpecs(fs);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
}, 'WebGL');
diff --git a/Specs/Renderer/ClearSpec.js b/Specs/Renderer/ClearSpec.js
index 609cfdd6b61d..e0dd41fb32c9 100644
--- a/Specs/Renderer/ClearSpec.js
+++ b/Specs/Renderer/ClearSpec.js
@@ -29,23 +29,23 @@ defineSuite([
it('default clear', function() {
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
});
it('clears to white', function() {
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new ClearCommand({
color : Color.WHITE
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('clears with a color mask', function() {
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new ClearCommand({
color : Color.WHITE,
@@ -54,12 +54,12 @@ defineSuite([
red : true,
green : false,
blue : true,
- alpha : false
+ alpha : true
}
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 255, 0]);
+ expect(context).toReadPixels([255, 0, 255, 255]);
});
it('clears with scissor test', function() {
@@ -68,7 +68,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
command.color = Color.BLACK;
command.renderState = RenderState.fromCache({
@@ -79,7 +79,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
command.renderState = RenderState.fromCache({
scissorTest : {
@@ -89,7 +89,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 255]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
});
it('clears a framebuffer color attachment', function() {
@@ -109,9 +109,10 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels({
+ expect({
+ context : context,
framebuffer : framebuffer
- })).toEqual([0, 255, 0, 255]);
+ }).toReadPixels([0, 255, 0, 255]);
framebuffer = framebuffer.destroy();
});
diff --git a/Specs/Renderer/ComputeCommandSpec.js b/Specs/Renderer/ComputeCommandSpec.js
index 6587501ff309..62530e84bf0f 100644
--- a/Specs/Renderer/ComputeCommandSpec.js
+++ b/Specs/Renderer/ComputeCommandSpec.js
@@ -83,13 +83,16 @@ defineSuite([
var shaderProgram = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vertexShader,
- fragmentShaderSource : fragmentShader
+ fragmentShaderSource : fragmentShader,
+ attributeLocations : {
+ position : 0
+ }
});
var vertexArray = new VertexArray({
context : context,
attributes : [{
- index : shaderProgram.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -153,9 +156,9 @@ defineSuite([
viewportQuad.material = Material.fromType(Material.ImageType);
viewportQuad.material.uniforms.image = outputTexture;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(new CommandMockPrimitive(computeCommand));
scene.primitives.add(viewportQuad);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Renderer/ContextSpec.js b/Specs/Renderer/ContextSpec.js
index 4ab506be82b1..5fc3b592fe39 100644
--- a/Specs/Renderer/ContextSpec.js
+++ b/Specs/Renderer/ContextSpec.js
@@ -6,8 +6,7 @@ defineSuite([
'Renderer/Buffer',
'Renderer/BufferUsage',
'Renderer/ContextLimits',
- 'Specs/createContext',
- 'Specs/renderFragment'
+ 'Specs/createContext'
], function(
Context,
Color,
@@ -15,8 +14,7 @@ defineSuite([
Buffer,
BufferUsage,
ContextLimits,
- createContext,
- renderFragment) {
+ createContext) {
'use strict';
var context;
@@ -40,26 +38,6 @@ defineSuite([
expect(context.canvas).not.toBeNull();
});
- it('get redBits', function() {
- expect(context.redBits).toEqual(8);
- });
-
- it('get greenBits', function() {
- expect(context.greenBits).toEqual(8);
- });
-
- it('get blueBits', function() {
- expect(context.blueBits).toEqual(8);
- });
-
- it('get alphaBits', function() {
- expect(context.alphaBits).toEqual(8);
- });
-
- it('get depthBits', function() {
- expect(context.depthBits).toBeGreaterThanOrEqualTo(16);
- });
-
it('get stencilBits', function() {
expect(context.stencilBits).toBeGreaterThanOrEqualTo(0);
});
@@ -157,13 +135,11 @@ defineSuite([
fs += '}';
- var pixel = renderFragment(context, fs);
-
- if (context.standardDerivatives) {
- expect(pixel).toEqual([0, 0, 255, 255]);
- } else {
- expect(pixel).toEqual([255, 255, 255, 255]);
- }
+ var expected = context.standardDerivatives ? [0, 0, 255, 255] : [255, 255, 255, 255];
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender(expected);
});
it('gets the element index uint extension', function() {
@@ -219,8 +195,11 @@ defineSuite([
' gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n' +
'}';
- var pixel = renderFragment(context, fs, 0.5, true);
- expect(pixel).toEqual([255, 0, 0, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ depth : 0.5
+ }).contextToRender([255, 0, 0, 255]);
var fsFragDepth = '';
@@ -243,13 +222,13 @@ defineSuite([
fsFragDepth += '}\n';
- pixel = renderFragment(context, fsFragDepth, 1.0, false);
-
- if (context.fragmentDepth) {
- expect(pixel).toEqual([0, 255, 0, 255]);
- } else {
- expect(pixel).toEqual([255, 0, 0, 255]);
- }
+ var expected = context.fragmentDepth ? [0, 255, 0, 255] : [255, 0, 0, 255];
+ expect({
+ context : context,
+ fragmentShader : fsFragDepth,
+ depth : 1.0,
+ clear : false
+ }).contextToRender(expected);
});
it('get the draw buffers extension', function() {
diff --git a/Specs/Renderer/CubeMapSpec.js b/Specs/Renderer/CubeMapSpec.js
index e2887ea9865e..fdccaaf26ab5 100644
--- a/Specs/Renderer/CubeMapSpec.js
+++ b/Specs/Renderer/CubeMapSpec.js
@@ -46,10 +46,47 @@ defineSuite([
'use strict';
var context;
- var sp;
- var va;
var cubeMap;
+ function expectCubeMapFaces(options) {
+ var cubeMap = options.cubeMap;
+ var expectedColors = options.expectedColors;
+
+ var fs =
+ 'uniform samplerCube u_texture;' +
+ 'uniform mediump vec3 u_direction;' +
+ 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
+
+ var faceDirections = [
+ new Cartesian3(1.0, 0.0, 0.0), // +X
+ new Cartesian3(-1.0, 0.0, 0.0), // -X
+ new Cartesian3(0.0, 1.0, 0.0), // +Y
+ new Cartesian3(0.0, -1.0, 0.0), // -Y
+ new Cartesian3(0.0, 0.0, 1.0), // +Z
+ new Cartesian3(0.0, 0.0, -1.0) // -Z
+ ];
+
+ var uniformMap = {
+ direction : undefined,
+
+ u_texture : function() {
+ return cubeMap;
+ },
+ u_direction : function() {
+ return this.direction;
+ }
+ };
+
+ for (var i = 0; i < 6; ++i) {
+ uniformMap.direction = faceDirections[i];
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender(expectedColors[i]);
+ }
+ }
+
var greenImage;
var blueImage;
var blueAlphaImage;
@@ -80,8 +117,6 @@ defineSuite([
});
afterEach(function() {
- sp = sp && sp.destroy();
- va = va && va.destroy();
cubeMap = cubeMap && cubeMap.destroy();
});
@@ -174,70 +209,17 @@ defineSuite([
}
});
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
-
- sp.allUniforms.u_texture.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 0, 255, 255], // +X is blue
+ [0, 255, 0, 255], // -X is green
+ [0, 0, 255, 255], // +Y is blue
+ [0, 255, 0, 255], // -Y is green
+ [0, 0, 255, 255], // +Z is blue
+ [0, 255, 0, 255] // -Z is green
+ ]
});
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
-
- // +X is blue
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -X is green
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
-
- // +Y is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -Y is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
-
- // +Z is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -Z is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
});
it('draws with a cube map with premultiplied alpha', function() {
@@ -255,131 +237,31 @@ defineSuite([
});
expect(cubeMap.preMultiplyAlpha).toEqual(true);
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
-
- sp.allUniforms.u_texture.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 0, 127, 255], // +X
+ [0, 0, 127, 255], // -X
+ [0, 0, 127, 255], // +Y
+ [0, 0, 127, 255], // -Y
+ [0, 0, 127, 255], // +Z
+ [0, 0, 127, 255] // -Z
+ ]
});
-
- // +X is blue
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
-
- // -X is green
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
-
- // +Y is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
-
- // -Y is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
-
- // +Z is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
-
- // -Z is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 127, 127]);
});
it('draws the context default cube map', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
+ expectCubeMapFaces({
+ cubeMap : context.defaultCubeMap,
+ expectedColors : [
+ [255, 255, 255, 255], // +X
+ [255, 255, 255, 255], // -X
+ [255, 255, 255, 255], // +Y
+ [255, 255, 255, 255], // -Y
+ [255, 255, 255, 255], // +Z
+ [255, 255, 255, 255] // -Z
+ ]
});
-
- sp.allUniforms.u_texture.value = context.defaultCubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
-
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
});
it('creates a cube map with typed arrays', function() {
@@ -389,201 +271,109 @@ defineSuite([
positiveX : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 0, 255])
+ arrayBufferView : new Uint8Array([0, 255, 255, 255])
},
negativeX : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 255, 0])
+ arrayBufferView : new Uint8Array([0, 0, 255, 255])
},
positiveY : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 255, 0, 0])
+ arrayBufferView : new Uint8Array([0, 255, 0, 255])
},
negativeY : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 0, 0, 0])
+ arrayBufferView : new Uint8Array([255, 0, 0, 255])
},
positiveZ : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 255, 255])
+ arrayBufferView : new Uint8Array([255, 0, 255, 255])
},
negativeZ : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 255, 0, 0])
+ arrayBufferView : new Uint8Array([255, 255, 0, 255])
}
}
});
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
-
- sp.allUniforms.u_texture.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 255, 255, 255], // +X
+ [0, 0, 255, 255], // -X
+ [0, 255, 0, 255], // +Y
+ [255, 0, 0, 255], // -Y
+ [255, 0, 255, 255], // +Z
+ [255, 255, 0, 255] // -Z
+ ]
});
-
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 0, 0]);
});
it('creates a cube map with floating-point textures', function() {
- if (context.floatingPointTexture) {
- var positiveXColor = new Color(0.0, 0.0, 0.0, 1.0);
- var negativeXColor = new Color(0.0, 0.0, 1.0, 0.0);
- var positiveYColor = new Color(0.0, 1.0, 0.0, 0.0);
- var negativeYColor = new Color(1.0, 0.0, 0.0, 0.0);
- var positiveZColor = new Color(0.0, 0.0, 1.0, 1.0);
- var negativeZColor = new Color(1.0, 1.0, 0.0, 0.0);
-
- cubeMap = new CubeMap({
- context : context,
- source : {
- positiveX : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([positiveXColor.red, positiveXColor.green, positiveXColor.blue, positiveXColor.alpha])
- },
- negativeX : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([negativeXColor.red, negativeXColor.green, negativeXColor.blue, negativeXColor.alpha])
- },
- positiveY : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([positiveYColor.red, positiveYColor.green, positiveYColor.blue, positiveYColor.alpha])
- },
- negativeY : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([negativeYColor.red, negativeYColor.green, negativeYColor.blue, negativeYColor.alpha])
- },
- positiveZ : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([positiveZColor.red, positiveZColor.green, positiveZColor.blue, positiveZColor.alpha])
- },
- negativeZ : {
- width : 1,
- height : 1,
- arrayBufferView : new Float32Array([negativeZColor.red, negativeZColor.green, negativeZColor.blue, negativeZColor.alpha])
- }
- },
- pixelDatatype : PixelDatatype.FLOAT
- });
+ if (!context.floatingPointTexture) {
+ return;
+ }
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
+ var positiveXColor = new Color(0.0, 1.0, 1.0, 1.0);
+ var negativeXColor = new Color(0.0, 0.0, 1.0, 1.0);
+ var positiveYColor = new Color(0.0, 1.0, 0.0, 1.0);
+ var negativeYColor = new Color(1.0, 0.0, 0.0, 1.0);
+ var positiveZColor = new Color(1.0, 0.0, 1.0, 1.0);
+ var negativeZColor = new Color(1.0, 1.0, 0.0, 1.0);
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ cubeMap = new CubeMap({
+ context : context,
+ source : {
+ positiveX : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([positiveXColor.red, positiveXColor.green, positiveXColor.blue, positiveXColor.alpha])
+ },
+ negativeX : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([negativeXColor.red, negativeXColor.green, negativeXColor.blue, negativeXColor.alpha])
+ },
+ positiveY : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([positiveYColor.red, positiveYColor.green, positiveYColor.blue, positiveYColor.alpha])
+ },
+ negativeY : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([negativeYColor.red, negativeYColor.green, negativeYColor.blue, negativeYColor.alpha])
+ },
+ positiveZ : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([positiveZColor.red, positiveZColor.green, positiveZColor.blue, positiveZColor.alpha])
+ },
+ negativeZ : {
+ width : 1,
+ height : 1,
+ arrayBufferView : new Float32Array([negativeZColor.red, negativeZColor.green, negativeZColor.blue, negativeZColor.alpha])
}
- });
-
- sp.allUniforms.u_texture.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
-
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual(positiveXColor.toBytes());
-
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual(negativeXColor.toBytes());
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual(positiveYColor.toBytes());
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual(negativeYColor.toBytes());
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual(positiveZColor.toBytes());
+ },
+ pixelDatatype : PixelDatatype.FLOAT
+ });
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual(negativeZColor.toBytes());
- }
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 255, 255, 255], // +X
+ [0, 0, 255, 255], // -X
+ [0, 255, 0, 255], // +Y
+ [255, 0, 0, 255], // -Y
+ [255, 0, 255, 255], // +Z
+ [255, 255, 0, 255] // -Z
+ ]
+ });
});
it('creates a cube map with typed arrays and images', function() {
@@ -595,12 +385,12 @@ defineSuite([
positiveY : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 255, 0, 0])
+ arrayBufferView : new Uint8Array([0, 255, 0, 255])
},
negativeY : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 0, 0, 0])
+ arrayBufferView : new Uint8Array([255, 0, 0, 255])
},
positiveZ : {
width : 1,
@@ -610,69 +400,22 @@ defineSuite([
negativeZ : {
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 255, 0, 0])
+ arrayBufferView : new Uint8Array([255, 255, 0, 255])
}
}
});
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_texture;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_texture, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
-
- sp.allUniforms.u_texture.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 0, 255, 255], // +X
+ [0, 255, 0, 255], // -X
+ [0, 255, 0, 255], // +Y
+ [255, 0, 0, 255], // -Y
+ [0, 0, 255, 255], // +Z
+ [255, 255, 0, 255] // -Z
+ ]
});
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
-
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 0, 0]);
});
it('copies to a cube map', function() {
@@ -688,70 +431,17 @@ defineSuite([
cubeMap.positiveZ.copyFrom(blueImage);
cubeMap.negativeZ.copyFrom(greenImage);
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_cubeMap;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_cubeMap, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 0, 255, 255], // +X
+ [0, 255, 0, 255], // -X
+ [0, 0, 255, 255], // +Y
+ [0, 255, 0, 255], // -Y
+ [0, 0, 255, 255], // +Z
+ [0, 255, 0, 255] // -Z
+ ]
});
-
- sp.allUniforms.u_cubeMap.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
-
- // +X is blue
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -X is green
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
-
- // +Y is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -Y is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
-
- // +Z is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- // -Z is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
});
it('copies from a typed array', function() {
@@ -763,155 +453,98 @@ defineSuite([
cubeMap.positiveX.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 0, 255])
+ arrayBufferView : new Uint8Array([0, 255, 255, 255])
});
cubeMap.negativeX.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 255, 0])
+ arrayBufferView : new Uint8Array([0, 0, 255, 255])
});
cubeMap.positiveY.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 255, 0, 0])
+ arrayBufferView : new Uint8Array([0, 255, 0, 255])
});
cubeMap.negativeY.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 0, 0, 0])
+ arrayBufferView : new Uint8Array([255, 0, 0, 255])
});
cubeMap.positiveZ.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([0, 0, 255, 255])
+ arrayBufferView : new Uint8Array([255, 0, 255, 255])
});
cubeMap.negativeZ.copyFrom({
width : 1,
height : 1,
- arrayBufferView : new Uint8Array([255, 255, 0, 0])
- });
-
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs =
- 'uniform samplerCube u_cubeMap;' +
- 'uniform mediump vec3 u_direction;' +
- 'void main() { gl_FragColor = textureCube(u_cubeMap, normalize(u_direction)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
-
- sp.allUniforms.u_cubeMap.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
+ arrayBufferView : new Uint8Array([255, 255, 0, 255])
});
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
+ expectCubeMapFaces({
+ cubeMap : cubeMap,
+ expectedColors : [
+ [0, 255, 255, 255], // +X
+ [0, 0, 255, 255], // -X
+ [0, 255, 0, 255], // +Y
+ [255, 0, 0, 255], // -Y
+ [255, 0, 255, 255], // +Z
+ [255, 255, 0, 255] // -Z
+ ]
});
-
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 0]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
-
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 0, 0]);
});
it('copies from the framebuffer', function() {
+ var cxt = createContext({
+ webgl : {
+ alpha : true // Seems to be required for copyFromFramebuffer()
+ }
+ });
+
cubeMap = new CubeMap({
- context : context,
+ context : cxt,
width : 1,
height : 1
});
cubeMap.positiveX.copyFrom(blueImage);
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'uniform samplerCube u_cubeMap;' +
'void main() { gl_FragColor = textureCube(u_cubeMap, vec3(1.0, 0.0, 0.0)); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_cubeMap : function() {
+ return cubeMap;
}
- });
-
- sp.allUniforms.u_cubeMap.value = cubeMap;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
+ };
// +X is blue
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
+ expect({
+ context : cxt,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 255, 255]);
// Clear framebuffer to red and copy to +X face
var clearCommand = new ClearCommand({
color : new Color (1.0, 0.0, 0.0, 1.0)
});
- clearCommand.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ clearCommand.execute(cxt);
+ expect(cxt).toReadPixels([255, 0, 0, 255]);
cubeMap.positiveX.copyFromFramebuffer();
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ ClearCommand.ALL.execute(cxt);
+ expect(cxt).toReadPixels([0, 0, 0, 0]);
// +X is red now
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ expect({
+ context : cxt,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([255, 0, 0, 255]);
+
+ cxt.destroyForSpecs();
});
it('draws with a cube map and a texture', function() {
@@ -932,43 +565,25 @@ defineSuite([
source : blueImage
});
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'uniform samplerCube u_cubeMap;' +
'uniform sampler2D u_texture;' +
'void main() { gl_FragColor = textureCube(u_cubeMap, vec3(1.0, 0.0, 0.0)) + texture2D(u_texture, vec2(0.0)); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_cubeMap : function() {
+ return cubeMap;
+ },
+ u_texture : function() {
+ return texture;
}
- });
+ };
- sp.allUniforms.u_cubeMap.value = cubeMap;
- sp.allUniforms.u_texture.value = texture;
-
- va = new VertexArray({
+ expect({
context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 255, 255]);
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 255, 255, 255]);
texture = texture.destroy();
});
@@ -991,41 +606,21 @@ defineSuite([
minificationFilter : TextureMinificationFilter.NEAREST_MIPMAP_LINEAR
});
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'uniform samplerCube u_cubeMap;' +
'void main() { gl_FragColor = textureCube(u_cubeMap, vec3(1.0, 0.0, 0.0)); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_cubeMap : function() {
+ return cubeMap;
}
- });
+ };
- sp.allUniforms.u_cubeMap.value = cubeMap;
-
- va = new VertexArray({
+ expect({
context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 255, 255]);
});
it('destroys', function() {
diff --git a/Specs/Renderer/DrawSpec.js b/Specs/Renderer/DrawSpec.js
index 8ba91cdae046..287880010181 100644
--- a/Specs/Renderer/DrawSpec.js
+++ b/Specs/Renderer/DrawSpec.js
@@ -42,11 +42,7 @@ defineSuite([
var va;
beforeAll(function() {
- context = createContext({
- webgl : {
- stencil : true
- }
- });
+ context = createContext();
});
afterAll(function() {
@@ -59,38 +55,11 @@ defineSuite([
});
it('draws a white point', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs = 'void main() { gl_FragColor = vec4(1.0); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
-
- va = new VertexArray({
+ expect({
context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ fragmentShader : fs
+ }).contextToRender();
});
it('draws a white point with an index buffer', function() {
@@ -102,7 +71,10 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
// Two indices instead of one is a workaround for NVIDIA:
@@ -117,7 +89,7 @@ defineSuite([
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -129,7 +101,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -137,7 +109,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
sp = sp.destroy();
va = va.destroy();
@@ -158,13 +130,17 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0,
+ intensity : 1
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -172,7 +148,7 @@ defineSuite([
}),
componentsPerAttribute : 4
}, {
- index : sp.vertexAttributes.intensity.index,
+ index : 1,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([1]),
@@ -183,7 +159,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -191,7 +167,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ expect(context).toReadPixels([255, 0, 0, 255]);
});
it('draws a red point with one interleaved vertex buffers', function() {
@@ -208,7 +184,11 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0,
+ intensity : 1
+ }
});
var stride = 5 * Float32Array.BYTES_PER_ELEMENT;
@@ -221,13 +201,13 @@ defineSuite([
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : vertexBuffer,
componentsPerAttribute : 4,
offsetInBytes : 0,
strideInBytes : stride
}, {
- index : sp.vertexAttributes.intensity.index,
+ index : 1,
vertexBuffer : vertexBuffer,
componentsPerAttribute : 1,
offsetInBytes : 4 * Float32Array.BYTES_PER_ELEMENT,
@@ -236,7 +216,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -244,7 +224,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ expect(context).toReadPixels([255, 0, 0, 255]);
});
it('draws with scissor test', function() {
@@ -253,13 +233,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -271,7 +254,7 @@ defineSuite([
// 1 of 3: Clear to black
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 3: Render point - fails scissor test
var command = new DrawCommand({
@@ -286,7 +269,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 3: Render point - passes scissor test
command = new DrawCommand({
@@ -301,7 +284,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with color mask', function() {
@@ -310,13 +293,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -328,7 +314,7 @@ defineSuite([
// 1 of 3: Clear to black
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 3: Render point - blue color mask
var command = new DrawCommand({
@@ -345,7 +331,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 0]);
+ expect(context).toReadPixels([255, 0, 0, 255]);
// 3 of 3: Render point - red color mask (blue channel not touched)
command = new DrawCommand({
@@ -362,24 +348,33 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 255, 0]);
+ expect(context).toReadPixels([255, 0, 255, 255]);
});
it('draws with additive blending', function() {
+ var cxt = createContext({
+ webgl : {
+ alpha : true
+ }
+ });
+
var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs = 'void main() { gl_FragColor = vec4(0.5); }';
- sp = ShaderProgram.fromCache({
- context : context,
+ var sp = ShaderProgram.fromCache({
+ context : cxt,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
- va = new VertexArray({
- context : context,
+ var va = new VertexArray({
+ context : cxt,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
- context : context,
+ context : cxt,
typedArray : new Float32Array([0, 0, 0, 1]),
usage : BufferUsage.STATIC_DRAW
}),
@@ -388,8 +383,8 @@ defineSuite([
});
// 1 of 3: Clear to black
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ ClearCommand.ALL.execute(cxt);
+ expect(cxt).toReadPixels([0, 0, 0, 0]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -409,29 +404,48 @@ defineSuite([
});
// 2 of 3: Blend: 0 + 0.5
- command.execute(context);
- expect(context.readPixels()).toEqualEpsilon([127, 127, 127, 127], 1);
+ command.execute(cxt);
+ expect({
+ context : cxt,
+ epsilon : 1
+ }).toReadPixels([127, 127, 127, 127]);
// 3 of 3: Blend: 0.5 + 0.5
- command.execute(context);
- expect(context.readPixels()).toEqualEpsilon([254, 254, 254, 254], 1);
+ command.execute(cxt);
+ expect({
+ context : cxt,
+ epsilon : 1
+ }).toReadPixels([254, 254, 254, 254]);
+
+ sp.destroy();
+ va.destroy();
+ cxt.destroyForSpecs();
});
it('draws with alpha blending', function() {
+ var cxt = createContext({
+ webgl : {
+ alpha : true
+ }
+ });
+
var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs = 'void main() { gl_FragColor = vec4(1.0, 1.0, 1.0, 0.5); }';
- sp = ShaderProgram.fromCache({
- context : context,
+ var sp = ShaderProgram.fromCache({
+ context : cxt,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
- va = new VertexArray({
- context : context,
+ var va = new VertexArray({
+ context : cxt,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
- context : context,
+ context : cxt,
typedArray : new Float32Array([0, 0, 0, 1]),
usage : BufferUsage.STATIC_DRAW
}),
@@ -440,8 +454,8 @@ defineSuite([
});
// 1 of 3: Clear to black
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ ClearCommand.ALL.execute(cxt);
+ expect(cxt).toReadPixels([0, 0, 0, 0]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -461,12 +475,22 @@ defineSuite([
});
// 2 of 3: Blend: RGB: (255 * 0.5) + (0 * 0.5), Alpha: 0.5 + 0
- command.execute(context);
- expect(context.readPixels()).toEqualEpsilon([127, 127, 127, 127], 1);
+ command.execute(cxt);
+ expect({
+ context : cxt,
+ epsilon : 1
+ }).toReadPixels([127, 127, 127, 127]);
// 3 of 3: Blend: RGB: (255 * 0.5) + (127 * 0.5), Alpha: 0.5 + 0
- command.execute(context);
- expect(context.readPixels()).toEqualEpsilon([191, 191, 191, 127], 2);
+ command.execute(cxt);
+ expect({
+ context : cxt,
+ epsilon : 2
+ }).toReadPixels([191, 191, 191, 127]);
+
+ sp.destroy();
+ va.destroy();
+ cxt.destroyForSpecs();
});
it('draws with blend color', function() {
@@ -475,13 +499,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -492,7 +519,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -520,7 +547,10 @@ defineSuite([
// 2 of 3: Blend: RGB: 255 - 127, Alpha: 255 - (255 - 255)
// Epsilon of 1 because ANGLE gives 127 and desktop GL gives 128.
command.execute(context);
- expect(context.readPixels()).toEqualEpsilon([128, 128, 128, 255], 1);
+ expect({
+ context : context,
+ epsilon : 1
+ }).toReadPixels([128, 128, 128, 255]);
});
it('draws with culling', function() {
@@ -529,13 +559,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, -1000, 0, 1, -1000, 1000, 0, 1, 1000, 1000, 0, 1]),
@@ -547,7 +580,7 @@ defineSuite([
// 1 of 3: Clear to black
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 3: Cull front faces - nothing is drawn
var command = new DrawCommand({
@@ -562,7 +595,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 3: Cull back faces - nothing is culled
command = new DrawCommand({
@@ -577,7 +610,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with front face winding order', function() {
@@ -586,13 +619,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, -1000, 0, 1, -1000, 1000, 0, 1, 1000, 1000, 0, 1]),
@@ -604,7 +640,7 @@ defineSuite([
// 1 of 3: Clear to black
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 3: Cull back faces with opposite winding order - nothing is drawn
var command = new DrawCommand({
@@ -620,7 +656,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 3: Cull back faces with correct winding order - nothing is culled
command = new DrawCommand({
@@ -636,7 +672,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with the depth test', function() {
@@ -645,13 +681,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, -1000, 0, 1, -1000, 1000, 0, 1, 1000, 1000, 0, 1]),
@@ -680,20 +719,20 @@ defineSuite([
depth : 1.0
});
clearCommand.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
// 2 of 2. Triangle fan fails the depth test.
clearCommand.color = new Color (0.0, 0.0, 0.0, 0.0);
clearCommand.depth = 0.0;
clearCommand.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
});
it('draws with depth range', function() {
@@ -702,13 +741,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -719,7 +761,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -733,7 +775,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([64, 191, 0, 255]);
+ expect(context).toReadPixels([64, 191, 0, 255]);
});
it('draws with line width', function() {
@@ -742,13 +784,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, 1000, 0, 1]),
@@ -759,7 +804,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.LINES,
@@ -775,7 +820,7 @@ defineSuite([
// I believe different GL implementations are allowed to AA
// in different ways (or at least that is what we see in practice),
// so verify it at least rendered something.
- expect(context.readPixels()).not.toEqual([0, 0, 0, 0]);
+ expect(context).notToReadPixels([0, 0, 0, 255]);
});
it('draws with polygon offset', function() {
@@ -784,13 +829,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -801,7 +849,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -816,7 +864,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with sample coverage', function() {
@@ -830,13 +878,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -847,7 +898,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -862,7 +913,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -875,7 +926,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with stencil test (front)', function() {
@@ -888,13 +939,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, -1000, 0, 1, -1000, 1000, 0, 1, 1000, 1000, 0, 1]),
@@ -915,7 +969,7 @@ defineSuite([
// 1 of 4. Clear, including stencil
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 4. Render where stencil is set - nothing is drawn
var command = new DrawCommand({
@@ -925,7 +979,7 @@ defineSuite([
renderState : rs
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 4. Render to stencil only, increment
command = new DrawCommand({
@@ -948,7 +1002,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 4 of 4. Render where stencil is set
command = new DrawCommand({
@@ -958,7 +1012,7 @@ defineSuite([
renderState : rs
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with stencil test (back)', function() {
@@ -971,13 +1025,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([-1000, -1000, 0, 1, 1000, -1000, 0, 1, -1000, 1000, 0, 1, 1000, 1000, 0, 1]),
@@ -998,7 +1055,7 @@ defineSuite([
// 1 of 4. Clear, including stencil
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 4. Render where stencil is set - nothing is drawn
var command = new DrawCommand({
@@ -1008,7 +1065,7 @@ defineSuite([
renderState : rs
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 4. Render to stencil only, increment
command = new DrawCommand({
@@ -1032,7 +1089,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 4 of 4. Render where stencil is set
command = new DrawCommand({
@@ -1042,7 +1099,7 @@ defineSuite([
renderState : rs
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws with an offset and count', function() {
@@ -1051,13 +1108,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, -1, 0, 0, 0, 1]),
@@ -1068,7 +1128,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// The first point in the vertex buffer does not generate any pixels
var command = new DrawCommand({
@@ -1079,7 +1139,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -1089,7 +1149,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('draws two instances of a point with different per-instance colors', function() {
@@ -1107,13 +1167,17 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0,
+ color: 1
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -1121,7 +1185,7 @@ defineSuite([
}),
componentsPerAttribute : 4
}, {
- index : sp.vertexAttributes.color.index,
+ index : 1,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Uint8Array([255, 0, 0, 255, 0, 255, 0, 255]),
@@ -1135,7 +1199,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -1147,7 +1211,7 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 0, 255]);
+ expect(context).toReadPixels([255, 255, 0, 255]);
}
});
@@ -1243,13 +1307,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -1278,13 +1345,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
diff --git a/Specs/Renderer/FramebufferSpec.js b/Specs/Renderer/FramebufferSpec.js
index 950bbffcbcff..88f31c03e0a6 100644
--- a/Specs/Renderer/FramebufferSpec.js
+++ b/Specs/Renderer/FramebufferSpec.js
@@ -166,11 +166,11 @@ defineSuite([
});
it('clears a color attachment', function() {
- // 1 of 4. Clear default color buffer to black.
+ // 1 of 3. Clear default color buffer to black.
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
- // 2 of 4. Clear framebuffer color attachment to green.
+ // 2 of 3. Clear framebuffer color attachment to green.
var colorTexture = new Texture({
context : context,
width : 1,
@@ -187,42 +187,19 @@ defineSuite([
});
clearCommand.execute(context);
- // 3 of 4. Verify default color buffer is still black.
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
-
- // 4 of 4. Render green to default color buffer by reading from previous color attachment
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
+ // 3 of 3. Render green to default color buffer by reading from previous color attachment
var fs = 'uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, vec2(0.0)); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_texture : function() {
+ return colorTexture;
}
- });
- sp.allUniforms.u_texture.value = colorTexture;
+ };
- va = new VertexArray({
+ expect({
context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 255, 0, 255]);
});
it('clears a cube map face color attachment', function() {
@@ -232,11 +209,11 @@ defineSuite([
height : 1
});
- // 1 of 4. Clear default color buffer to black.
+ // 1 of 3. Clear default color buffer to black.
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
- // 2 of 4. Clear framebuffer color attachment to green.
+ // 2 of 3. Clear framebuffer color attachment to green.
framebuffer = new Framebuffer({
context : context,
colorTextures : [cubeMap.positiveX],
@@ -249,42 +226,19 @@ defineSuite([
});
clearCommand.execute(context);
- // 3 of 4. Verify default color buffer is still black.
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
-
- // 4 of 4. Render green to default color buffer by reading from previous color attachment
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
+ // 3 of 3. Render green to default color buffer by reading from previous color attachment
var fs = 'uniform samplerCube u_cubeMap; void main() { gl_FragColor = textureCube(u_cubeMap, vec3(1.0, 0.0, 0.0)); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_cubeMap : function() {
+ return cubeMap;
}
- });
- sp.allUniforms.u_cubeMap.value = cubeMap;
+ };
- va = new VertexArray({
+ expect({
context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 255, 0, 255]);
cubeMap = cubeMap.destroy();
});
@@ -302,7 +256,7 @@ defineSuite([
// 1 of 4. Clear default color buffer to black.
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 2 of 4. Render green point into color attachment.
var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
@@ -310,13 +264,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations : {
+ position : 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -335,30 +292,21 @@ defineSuite([
command.execute(context);
// 3 of 4. Verify default color buffer is still black.
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 4 of 4. Render green to default color buffer by reading from previous color attachment
- var vs2 = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs2 = 'uniform sampler2D u_texture; void main() { gl_FragColor = texture2D(u_texture, vec2(0.0)); }';
- var sp2 = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs2,
- fragmentShaderSource : fs2,
- attributeLocations : {
- position : 0
+ var uniformMap = {
+ u_texture : function() {
+ return colorTexture;
}
- });
- sp2.allUniforms.u_texture.value = colorTexture;
-
- command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp2,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ };
- sp2 = sp2.destroy();
+ expect({
+ context : context,
+ fragmentShader : fs2,
+ uniformMap : uniformMap
+ }).contextToRender([0, 255, 0, 255]);
});
function renderDepthAttachment(framebuffer, texture) {
@@ -370,13 +318,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations : {
+ position : 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -400,7 +351,7 @@ defineSuite([
command.execute(context);
// 2 of 3. Verify default color buffer is still black.
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
// 3 of 3. Render green to default color buffer by reading from previous color attachment
var vs2 = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
@@ -413,12 +364,17 @@ defineSuite([
position : 0
}
});
- sp2.allUniforms.u_texture.value = texture;
+ var uniformMap = {
+ u_texture : function() {
+ return texture;
+ }
+ };
command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
shaderProgram : sp2,
- vertexArray : va
+ vertexArray : va,
+ uniformMap : uniformMap
});
command.execute(context);
@@ -446,7 +402,7 @@ defineSuite([
});
if (framebuffer.status === WebGLConstants.FRAMEBUFFER_COMPLETE) {
- expect(renderDepthAttachment(framebuffer, framebuffer.depthTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ expect(renderDepthAttachment(framebuffer, framebuffer.depthTexture)).toEqualEpsilon([128, 128, 128, 255], 1);
}
}
});
@@ -470,7 +426,7 @@ defineSuite([
});
if (framebuffer.status === WebGLConstants.FRAMEBUFFER_COMPLETE) {
- expect(renderDepthAttachment(framebuffer, framebuffer.depthStencilTexture)).toEqualEpsilon([128, 128, 128, 128], 1);
+ expect(renderDepthAttachment(framebuffer, framebuffer.depthStencilTexture)).toEqualEpsilon([128, 128, 128, 255], 1);
}
}
});
@@ -496,13 +452,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations : {
+ position : 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
@@ -519,9 +478,10 @@ defineSuite([
framebuffer : framebuffer
});
clearCommand.execute(context);
- expect(context.readPixels({
+ expect({
+ context : context,
framebuffer : framebuffer
- })).toEqual([0, 0, 0, 0]);
+ }).toReadPixels([0, 0, 0, 0]);
// 2 of 3. Does not pass depth test
var command = new DrawCommand({
@@ -537,9 +497,10 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels({
+ expect({
+ context : context,
framebuffer : framebuffer
- })).toEqual([0, 0, 0, 0]);
+ }).toReadPixels([0, 0, 0, 0]);
// 3 of 3. Passes depth test
command = new DrawCommand({
@@ -555,104 +516,117 @@ defineSuite([
})
});
command.execute(context);
- expect(context.readPixels({
+ expect({
+ context : context,
framebuffer : framebuffer
- })).toEqual([255, 255, 255, 255]);
+ }).toReadPixels([255, 255, 255, 255]);
});
it('draws with multiple render targets', function() {
- if (context.drawBuffers) {
- var colorTexture0 = new Texture({
- context : context,
- width : 1,
- height : 1
- });
- var colorTexture1 = new Texture({
- context : context,
- width : 1,
- height : 1
- });
- framebuffer = new Framebuffer({
- context : context,
- colorTextures : [colorTexture0, colorTexture1]
- });
+ if (!context.drawBuffers) {
+ return;
+ }
- // 1 of 5. Clear default color buffer to black.
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ var colorTexture0 = new Texture({
+ context : context,
+ width : 1,
+ height : 1
+ });
+ var colorTexture1 = new Texture({
+ context : context,
+ width : 1,
+ height : 1
+ });
+ framebuffer = new Framebuffer({
+ context : context,
+ colorTextures : [colorTexture0, colorTexture1]
+ });
- // 2 of 5. Render red point into color attachment 0 and green point to color attachment 1.
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs = '#extension GL_EXT_draw_buffers : enable \n void main() { gl_FragData[0] = vec4(1.0, 0.0, 0.0, 1.0); gl_FragData[1] = vec4(0.0, 1.0, 0.0, 1.0); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
+ // 1 of 5. Clear default color buffer to black.
+ ClearCommand.ALL.execute(context);
+ expect(context).toReadPixels([0, 0, 0, 255]);
- va = new VertexArray({
- context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
+ // 2 of 5. Render red point into color attachment 0 and green point to color attachment 1.
+ var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
+ var fs = '#extension GL_EXT_draw_buffers : enable \n void main() { gl_FragData[0] = vec4(1.0, 0.0, 0.0, 1.0); gl_FragData[1] = vec4(0.0, 1.0, 0.0, 1.0); }';
+ sp = ShaderProgram.fromCache({
+ context : context,
+ vertexShaderSource : vs,
+ fragmentShaderSource : fs,
+ attributeLocations : {
+ position : 0
+ }
+ });
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va,
- framebuffer : framebuffer
- });
- command.execute(context);
+ va = new VertexArray({
+ context : context,
+ attributes : [{
+ index : 0,
+ vertexBuffer : Buffer.createVertexBuffer({
+ context : context,
+ typedArray : new Float32Array([0, 0, 0, 1]),
+ usage : BufferUsage.STATIC_DRAW
+ }),
+ componentsPerAttribute : 4
+ }]
+ });
- // 3 of 5. Verify default color buffer is still black.
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ var command = new DrawCommand({
+ primitiveType : PrimitiveType.POINTS,
+ shaderProgram : sp,
+ vertexArray : va,
+ framebuffer : framebuffer
+ });
+ command.execute(context);
- // 4 of 5. Render yellow to default color buffer by reading from previous color attachments
- var vs2 = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
- var fs2 = 'uniform sampler2D u_texture0; uniform sampler2D u_texture1; void main() { gl_FragColor = texture2D(u_texture0, vec2(0.0)) + texture2D(u_texture1, vec2(0.0)); }';
- var sp2 = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs2,
- fragmentShaderSource : fs2,
- attributeLocations : {
- position : 0
- }
- });
- sp2.allUniforms.u_texture0.value = colorTexture0;
- sp2.allUniforms.u_texture1.value = colorTexture1;
+ // 3 of 5. Verify default color buffer is still black.
+ expect(context).toReadPixels([0, 0, 0, 255]);
- command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp2,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 0, 255]);
+ // 4 of 5. Render yellow to default color buffer by reading from previous color attachments
+ var vs2 = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
+ var fs2 = 'uniform sampler2D u_texture0; uniform sampler2D u_texture1; void main() { gl_FragColor = texture2D(u_texture0, vec2(0.0)) + texture2D(u_texture1, vec2(0.0)); }';
+ var sp2 = ShaderProgram.fromCache({
+ context : context,
+ vertexShaderSource : vs2,
+ fragmentShaderSource : fs2,
+ attributeLocations : {
+ position : 0
+ }
+ });
+ var uniformMap = {
+ u_texture0 : function() {
+ return colorTexture0;
+ },
+ u_texture1 : function() {
+ return colorTexture1;
+ }
+ };
- // 5 of 5. Verify clearing multiple color attachments
- var clearCommand = new ClearCommand({
- color : new Color (0.0, 0.0, 0.0, 0.0),
- framebuffer : framebuffer
- });
- clearCommand.execute(context);
+ command = new DrawCommand({
+ primitiveType : PrimitiveType.POINTS,
+ shaderProgram : sp2,
+ vertexArray : va,
+ uniformMap : uniformMap
+ });
+ command.execute(context);
+ expect(context).toReadPixels([255, 255, 0, 255]);
- command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp2,
- vertexArray : va
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ // 5 of 5. Verify clearing multiple color attachments
+ var clearCommand = new ClearCommand({
+ color : new Color (0.0, 0.0, 0.0, 0.0),
+ framebuffer : framebuffer
+ });
+ clearCommand.execute(context);
- sp2 = sp2.destroy();
- }
+ command = new DrawCommand({
+ primitiveType : PrimitiveType.POINTS,
+ shaderProgram : sp2,
+ vertexArray : va
+ });
+ command.execute(context);
+ expect(context).toReadPixels([0, 0, 0, 255]);
+
+ sp2 = sp2.destroy();
});
it('gets the status of a complete framebuffer', function() {
@@ -674,6 +648,10 @@ defineSuite([
});
it('gets the status of a incomplete framebuffer', function() {
+ if (!!window.webglStub) {
+ return;
+ }
+
framebuffer = new Framebuffer({
context : context,
colorTextures : [new Texture({
@@ -819,13 +797,16 @@ defineSuite([
sp = ShaderProgram.fromCache({
context : context,
vertexShaderSource : vs,
- fragmentShaderSource : fs
+ fragmentShaderSource : fs,
+ attributeLocations : {
+ position : 0
+ }
});
va = new VertexArray({
context : context,
attributes : [{
- index : sp.vertexAttributes.position.index,
+ index : 0,
vertexBuffer : Buffer.createVertexBuffer({
context : context,
typedArray : new Float32Array([0, 0, 0, 1]),
diff --git a/Specs/Renderer/ShaderProgramSpec.js b/Specs/Renderer/ShaderProgramSpec.js
index c5528a195c65..fdb4e9e68f84 100644
--- a/Specs/Renderer/ShaderProgramSpec.js
+++ b/Specs/Renderer/ShaderProgramSpec.js
@@ -23,9 +23,9 @@ defineSuite([
createContext) {
'use strict';
+ var webglStub = !!window.webglStub;
var context;
var sp;
- var va;
var injectedTestFunctions = {
czm_circularDependency1 : 'void czm_circularDependency1() { czm_circularDependency2(); }',
@@ -51,7 +51,6 @@ defineSuite([
ShaderSource._czmBuiltinsAndUniforms[functionName] = injectedTestFunctions[functionName];
}
}
-
});
afterAll(function() {
@@ -64,33 +63,9 @@ defineSuite([
}
});
- function renderFragment(context, shaderProgram, uniformMap) {
- va = new VertexArray({
- context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : shaderProgram,
- vertexArray : va,
- uniformMap : uniformMap
- });
- command.execute(context);
-
- return context.readPixels();
- }
+ afterEach(function() {
+ sp = sp && sp.destroy();
+ });
it('has vertex and fragment shader source', function() {
var vs = 'void main() { gl_Position = vec4(1.0); }';
@@ -123,6 +98,10 @@ defineSuite([
fragmentShaderSource : fs
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.numberOfVertexAttributes).toEqual(1);
expect(sp.vertexAttributes.position.name).toEqual('position');
});
@@ -148,6 +127,10 @@ defineSuite([
attributeLocations : attributes
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.numberOfVertexAttributes).toEqual(3);
expect(sp.vertexAttributes.position.name).toEqual('position');
expect(sp.vertexAttributes.position.index).toEqual(attributes.position);
@@ -166,6 +149,10 @@ defineSuite([
fragmentShaderSource : fs
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.allUniforms.u_vec4.name).toEqual('u_vec4');
expect(sp.allUniforms.czm_viewport.name).toEqual('czm_viewport');
});
@@ -199,6 +186,10 @@ defineSuite([
fragmentShaderSource : fs
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.allUniforms.u_float.name).toEqual('u_float');
expect(sp.allUniforms.u_vec2.name).toEqual('u_vec2');
expect(sp.allUniforms.u_vec3.name).toEqual('u_vec3');
@@ -227,6 +218,10 @@ defineSuite([
fragmentShaderSource : fs
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.allUniforms['u_struct.f'].name).toEqual('u_struct.f');
expect(sp.allUniforms['u_struct.v'].name).toEqual('u_struct.v');
});
@@ -260,6 +255,10 @@ defineSuite([
fragmentShaderSource : fs
});
+ if (webglStub) {
+ return; // WebGL Stub does not return vertex attribute and uniforms in the shader
+ }
+
expect(sp.allUniforms.u_float.name).toEqual('u_float');
expect(sp.allUniforms.u_vec2.name).toEqual('u_vec2');
expect(sp.allUniforms.u_vec3.name).toEqual('u_vec3');
@@ -298,7 +297,6 @@ defineSuite([
});
it('has predefined constants', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { ' +
' float f = ((czm_pi > 0.0) && \n' +
@@ -314,17 +312,14 @@ defineSuite([
' (czm_degreesPerRadian > 0.0)) ? 1.0 : 0.0; \n' +
' gl_FragColor = vec4(f); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('has built-in constant, structs, and functions', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' czm_materialInput materialInput; \n' +
@@ -334,13 +329,11 @@ defineSuite([
' material.diffuse = czm_hue(material.diffuse, czm_twoPi); \n' +
' gl_FragColor = vec4(material.diffuse, material.alpha); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('creates duplicate uniforms if precision of uniforms in vertex and fragment shader do not match', function() {
@@ -348,69 +341,71 @@ defineSuite([
ContextLimits._highpFloatSupported = false;
var vs = 'attribute vec4 position; uniform float u_value; varying float v_value; void main() { gl_PointSize = 1.0; v_value = u_value * czm_viewport.z; gl_Position = position; }';
var fs = 'uniform float u_value; varying float v_value; void main() { gl_FragColor = vec4(u_value * v_value * czm_viewport.z); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
var uniformMap = {
u_value : function() {
return 1.0;
}
};
- expect(sp.allUniforms.u_value).toBeDefined();
- expect(sp.allUniforms.czm_mediump_u_value).toBeDefined();
- expect(renderFragment(context, sp, uniformMap)).not.toEqual([0, 0, 0, 0]);
+
+ sp = ShaderProgram.fromCache({
+ context : context,
+ vertexShaderSource : vs,
+ fragmentShaderSource : fs
+ });
+
+ if (!webglStub) {
+ // WebGL Stub does not return vertex attribute and uniforms in the shader
+ expect(sp.allUniforms.u_value).toBeDefined();
+ expect(sp.allUniforms.czm_mediump_u_value).toBeDefined();
+ }
+
+ expect({
+ context : context,
+ vertexShader : vs,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).notContextToRender([0, 0, 0, 0]);
+
ContextLimits._highpFloatSupported = highpFloatSupported;
});
it('1 level function dependency', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' czm_testFunction1(vec4(1.0)); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('2 level function dependency', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' czm_testFunction2(vec4(1.0)); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('3 level function dependency', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' czm_testFunction3(vec4(1.0)); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('diamond dependency', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' vec4 color = vec4(1.0, 1.0, 1.0, 0.8); \n' +
@@ -418,17 +413,14 @@ defineSuite([
' color = czm_testDiamondDependency2(color); \n' +
' gl_FragColor = color; \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('diamond plus 3 level function dependency', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' vec4 color = vec4(1.0, 1.0, 1.0, 0.8); \n' +
@@ -436,17 +428,14 @@ defineSuite([
' color = czm_testDiamondDependency2(color); \n' +
' czm_testFunction3(color); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('big mess of function dependencies', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' vec4 color = vec4(0.9, 0.9, 1.0, 0.6); \n' +
@@ -454,29 +443,24 @@ defineSuite([
' color = czm_testDiamondDependency2(color); \n' +
' czm_testFunction4(color); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('doc comment with reference to another function', function() {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
var fs =
'void main() { \n' +
' vec4 color = vec4(1.0, 1.0, 1.0, 1.0); \n' +
' czm_testFunctionWithComment(color); \n' +
'}';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
- expect(renderFragment(context, sp)).toEqual([255, 255, 255, 255]);
+ expect({
+ context : context,
+ fragmentShader : fs
+ }).contextToRender();
});
it('compiles with #version at the top', function() {
@@ -510,6 +494,10 @@ defineSuite([
});
it('fails vertex shader compile', function() {
+ if (webglStub) {
+ return; // WebGL Stub does not actually try to compile the shader
+ }
+
var vs = 'does not compile.';
var fs = 'void main() { gl_FragColor = vec4(1.0); }';
sp = ShaderProgram.fromCache({
@@ -524,6 +512,10 @@ defineSuite([
});
it('fails fragment shader compile', function() {
+ if (webglStub) {
+ return; // WebGL Stub does not actually try to compile the shader
+ }
+
var vs = 'void main() { gl_Position = vec4(0.0); }';
var fs = 'does not compile.';
sp = ShaderProgram.fromCache({
@@ -538,6 +530,10 @@ defineSuite([
});
it('fails to link', function() {
+ if (webglStub) {
+ return; // WebGL Stub does not actually try to compile and link the shader
+ }
+
var vs = 'void nomain() { }';
var fs = 'void nomain() { }';
sp = ShaderProgram.fromCache({
diff --git a/Specs/Renderer/TextureSpec.js b/Specs/Renderer/TextureSpec.js
index 49c70cf5dbd1..9d9f1725ece0 100644
--- a/Specs/Renderer/TextureSpec.js
+++ b/Specs/Renderer/TextureSpec.js
@@ -49,9 +49,15 @@ defineSuite([
var blueAlphaImage;
var blueOverRedImage;
- var sp;
- var va;
+ var fs =
+ 'uniform sampler2D u_texture;' +
+ 'void main() { gl_FragColor = texture2D(u_texture, vec2(0.0)); }';
var texture;
+ var uniformMap = {
+ u_texture : function() {
+ return texture;
+ }
+ };
beforeAll(function() {
context = createContext();
@@ -78,52 +84,9 @@ defineSuite([
});
afterEach(function() {
- sp = sp && sp.destroy();
- va = va && va.destroy();
texture = texture && texture.destroy();
});
- function renderFragment(context) {
- var vs = '';
- vs += 'attribute vec4 position;';
- vs += 'void main() { gl_PointSize = 1.0; gl_Position = position; }';
-
- var fs = '';
- fs += 'uniform sampler2D u_texture;';
- fs += 'void main() { gl_FragColor = texture2D(u_texture, vec2(0.0)); }';
-
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
- }
- });
- sp.allUniforms.u_texture.value = texture;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
-
- return context.readPixels();
- }
-
it('has expected default values for pixel format and datatype', function() {
texture = new Texture({
context : context,
@@ -148,9 +111,13 @@ defineSuite([
command.color = Color.WHITE;
command.execute(context);
- expect(context.readPixels()).toEqual(Color.WHITE.toBytes());
+ expect(context).toReadPixels([255, 255, 255, 255]);
- expect(renderFragment(context)).toEqual(Color.RED.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([255, 0, 0, 255]);
});
it('can copy from the framebuffer', function() {
@@ -161,24 +128,32 @@ defineSuite([
});
// Render blue
- expect(renderFragment(context)).toEqual(Color.BLUE.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 255, 255]);
// Clear to red
var command = new ClearCommand({
color : Color.RED
});
command.execute(context);
- expect(context.readPixels()).toEqual(Color.RED.toBytes());
+ expect(context).toReadPixels(Color.RED.toBytes());
texture.copyFromFramebuffer();
// Clear to white
command.color = Color.WHITE;
command.execute(context);
- expect(context.readPixels()).toEqual(Color.WHITE.toBytes());
+ expect(context).toReadPixels(Color.WHITE.toBytes());
// Render red
- expect(renderFragment(context)).toEqual(Color.RED.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([255, 0, 0, 255]);
});
it('draws the expected texture color', function() {
@@ -188,12 +163,16 @@ defineSuite([
pixelFormat : PixelFormat.RGBA
});
- expect(renderFragment(context)).toEqual(Color.BLUE.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 255, 255]);
});
it('draws the expected floating-point texture color', function() {
if (context.floatingPointTexture) {
- var color = new Color(0.2, 0.4, 0.6, 0.8);
+ var color = new Color(0.2, 0.4, 0.6, 1.0);
var floats = new Float32Array([color.red, color.green, color.blue, color.alpha]);
texture = new Texture({
@@ -207,21 +186,41 @@ defineSuite([
}
});
- var pixels = renderFragment(context);
- expect(pixels).toEqual(color.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender(color.toBytes());
}
});
it('renders with premultiplied alpha', function() {
- texture = new Texture({
- context : context,
+ var cxt = createContext({
+ webgl : {
+ alpha : true
+ }
+ });
+ var texture = new Texture({
+ context : cxt,
source : blueAlphaImage,
pixelFormat : PixelFormat.RGBA,
preMultiplyAlpha : true
});
+ var uniformMap = {
+ u_texture : function() {
+ return texture;
+ }
+ };
+
expect(texture.preMultiplyAlpha).toEqual(true);
+ expect({
+ context : cxt,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 127, 127]);
- expect(renderFragment(context)).toEqual([0, 0, 127, 127]);
+ texture.destroy();
+ cxt.destroyForSpecs();
});
it('draws textured blue and red points', function() {
@@ -231,56 +230,40 @@ defineSuite([
pixelFormat : PixelFormat.RGBA
});
- var vs = '';
- vs += 'attribute vec4 position;';
- vs += 'void main() { gl_PointSize = 1.0; gl_Position = position; }';
-
- var fs = '';
- fs += 'uniform sampler2D u_texture;';
- fs += 'uniform mediump vec2 u_txCoords;';
- fs += 'void main() { gl_FragColor = texture2D(u_texture, u_txCoords); }';
+ var fragmentShaderSource = '';
+ fragmentShaderSource += 'uniform sampler2D u_texture;';
+ fragmentShaderSource += 'uniform mediump vec2 u_txCoords;';
+ fragmentShaderSource += 'void main() { gl_FragColor = texture2D(u_texture, u_txCoords); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var txCoords;
+ var um = {
+ u_texture : function() {
+ return texture;
+ },
+ u_txCoords : function() {
+ return txCoords;
}
- });
- sp.allUniforms.u_texture.value = texture;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
+ };
// Blue on top
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.75);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.BLUE.toBytes());
+ txCoords = new Cartesian2(0.5, 0.75);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender([0, 0, 255, 255]);
// Red on bottom
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.25);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.RED.toBytes());
+ txCoords = new Cartesian2(0.5, 0.25);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender([255, 0, 0, 255]);
});
it('can be created from a typed array', function() {
- var bytes = new Uint8Array(Color.GREEN.toBytes());
+ var bytes = new Uint8Array([0, 255, 0, 255]);
texture = new Texture({
context : context,
@@ -293,7 +276,11 @@ defineSuite([
}
});
- expect(renderFragment(context)).toEqual(Color.GREEN.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 255, 0, 255]);
});
it('can copy from a typed array', function() {
@@ -312,7 +299,11 @@ defineSuite([
arrayBufferView : bytes
});
- expect(renderFragment(context)).toEqual(Color.NAVY.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender(Color.NAVY.toBytes());
});
it('can replace a subset of a texture', function() {
@@ -322,65 +313,55 @@ defineSuite([
pixelFormat : PixelFormat.RGBA
});
- var vs = '';
- vs += 'attribute vec4 position;';
- vs += 'void main() { gl_PointSize = 1.0; gl_Position = position; }';
-
- var fs = '';
- fs += 'uniform sampler2D u_texture;';
- fs += 'uniform mediump vec2 u_txCoords;';
- fs += 'void main() { gl_FragColor = texture2D(u_texture, u_txCoords); }';
+ var fragmentShaderSource = '';
+ fragmentShaderSource += 'uniform sampler2D u_texture;';
+ fragmentShaderSource += 'uniform mediump vec2 u_txCoords;';
+ fragmentShaderSource += 'void main() { gl_FragColor = texture2D(u_texture, u_txCoords); }';
- sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs,
- attributeLocations : {
- position : 0
+ var txCoords;
+ var um = {
+ u_texture : function() {
+ return texture;
+ },
+ u_txCoords : function() {
+ return txCoords;
}
- });
- sp.allUniforms.u_texture.value = texture;
-
- va = new VertexArray({
- context : context,
- attributes : [{
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
+ };
// Blue on top
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.75);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.BLUE.toBytes());
+ txCoords = new Cartesian2(0.5, 0.75);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender([0, 0, 255, 255]);
// Red on bottom
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.25);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.RED.toBytes());
+ txCoords = new Cartesian2(0.5, 0.25);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender([255, 0, 0, 255]);
// After copy...
texture.copyFrom(greenImage, 0, 1);
// Now green on top
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.75);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.LIME.toBytes());
+ txCoords = new Cartesian2(0.5, 0.75);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender(Color.LIME.toBytes());
// Still red on bottom
- sp.allUniforms.u_txCoords.value = new Cartesian2(0.5, 0.25);
- command.execute(context);
- expect(context.readPixels()).toEqual(Color.RED.toBytes());
+ txCoords = new Cartesian2(0.5, 0.25);
+ expect({
+ context : context,
+ fragmentShader : fragmentShaderSource,
+ uniformMap : um
+ }).contextToRender([255, 0, 0, 255]);
});
it('can generate mipmaps', function() {
@@ -394,7 +375,11 @@ defineSuite([
});
texture.generateMipmap();
- expect(renderFragment(context)).toEqual(Color.BLUE.toBytes());
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender([0, 0, 255, 255]);
});
it('can set a sampler property', function() {
diff --git a/Specs/Renderer/UniformSpec.js b/Specs/Renderer/UniformSpec.js
index b51f3c094ad6..6f3443932886 100644
--- a/Specs/Renderer/UniformSpec.js
+++ b/Specs/Renderer/UniformSpec.js
@@ -42,7 +42,11 @@ defineSuite([
' gl_FragColor = vec4(u == 1.0); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec2 uniform', function() {
@@ -58,7 +62,11 @@ defineSuite([
' gl_FragColor = vec4(u == vec2(0.25, 0.5)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec3 uniform (Cartesian3)', function() {
@@ -74,7 +82,11 @@ defineSuite([
' gl_FragColor = vec4(u == vec3(0.25, 0.5, 0.75)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec3 uniform (Color)', function() {
@@ -90,7 +102,11 @@ defineSuite([
' gl_FragColor = vec4(u == vec3(0.25, 0.5, 0.75)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec4 uniform (Cartesian4)', function() {
@@ -106,7 +122,11 @@ defineSuite([
' gl_FragColor = vec4(u == vec4(0.25, 0.5, 0.75, 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec4 uniform (Color)', function() {
@@ -122,7 +142,11 @@ defineSuite([
' gl_FragColor = vec4(u == vec4(0.25, 0.5, 0.75, 1.0)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets int uniform', function() {
@@ -138,7 +162,11 @@ defineSuite([
' gl_FragColor = vec4(u == 1); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec2 uniform', function() {
@@ -154,7 +182,11 @@ defineSuite([
' gl_FragColor = vec4(u == ivec2(1, 2)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec3 uniform', function() {
@@ -170,7 +202,11 @@ defineSuite([
' gl_FragColor = vec4(u == ivec3(1, 2, 3)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec4 uniform', function() {
@@ -186,7 +222,11 @@ defineSuite([
' gl_FragColor = vec4(u == ivec4(1, 2, 3, 4)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bool uniform', function() {
@@ -202,7 +242,11 @@ defineSuite([
' gl_FragColor = vec4(u); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec2 uniform', function() {
@@ -218,7 +262,11 @@ defineSuite([
' gl_FragColor = vec4(u == bvec2(true, false)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec3 uniform', function() {
@@ -234,7 +282,11 @@ defineSuite([
' gl_FragColor = vec4(u == bvec3(true, false, true)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec4 uniform', function() {
@@ -250,7 +302,11 @@ defineSuite([
' gl_FragColor = vec4(u == bvec4(true, false, true, false)); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat2 uniform', function() {
@@ -271,7 +327,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat3 uniform', function() {
@@ -294,7 +354,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat4 uniform', function() {
@@ -319,7 +383,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets a struct uniform', function() {
@@ -343,7 +411,11 @@ defineSuite([
//
// ' gl_FragColor = vec4((u.f == 2.5) && (u.v == vec4(0.25, 0.5, 0.75, 1.0))); '
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets float uniform array', function() {
@@ -366,7 +438,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec2 uniform array', function() {
@@ -388,7 +464,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec3 uniform array', function() {
@@ -410,7 +490,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets vec4 uniform array', function() {
@@ -432,7 +516,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets int uniform array', function() {
@@ -455,7 +543,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec2 uniform array', function() {
@@ -477,7 +569,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec3 uniform array', function() {
@@ -499,7 +595,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets ivec4 uniform array', function() {
@@ -521,7 +621,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bool uniform array', function() {
@@ -544,7 +648,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec2 uniform array', function() {
@@ -566,7 +674,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec3 uniform array', function() {
@@ -588,7 +700,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets bvec4 uniform array', function() {
@@ -610,7 +726,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat2 uniform array', function() {
@@ -639,7 +759,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat3 uniform array', function() {
@@ -672,7 +796,11 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
it('sets mat4 uniform array', function() {
@@ -709,6 +837,10 @@ defineSuite([
' ); ' +
'}';
- context.verifyDrawForSpecs(fs, uniformMap);
+ expect({
+ context : context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender();
});
}, 'WebGL');
diff --git a/Specs/Renderer/VertexArrayFactorySpec.js b/Specs/Renderer/VertexArrayFactorySpec.js
index 67af4eef7d6b..4ad2ee9c7cd8 100644
--- a/Specs/Renderer/VertexArrayFactorySpec.js
+++ b/Specs/Renderer/VertexArrayFactorySpec.js
@@ -328,7 +328,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -336,7 +336,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('sorts interleaved attributes from large to small components (2)', function() {
@@ -390,7 +390,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -400,7 +400,7 @@ defineSuite([
count : 1
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ expect(context).toReadPixels([255, 0, 0, 255]);
command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -410,7 +410,7 @@ defineSuite([
count : 1
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ expect(context).toReadPixels([0, 255, 0, 255]);
});
it('sorts interleaved attributes from large to small components (3)', function() {
@@ -476,7 +476,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -484,7 +484,7 @@ defineSuite([
vertexArray : va
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
});
it('creates a custom interleaved vertex', function() {
@@ -555,7 +555,7 @@ defineSuite([
});
ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
+ expect(context).toReadPixels([0, 0, 0, 255]);
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
@@ -565,7 +565,7 @@ defineSuite([
count : 1
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 0, 0, 255]);
+ expect(context).toReadPixels([255, 0, 0, 255]);
var vs2 =
'attribute vec3 position; ' +
@@ -599,7 +599,7 @@ defineSuite([
count : 1
});
command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ expect(context).toReadPixels([0, 255, 0, 255]);
});
it('creates an index buffer', function() {
diff --git a/Specs/Renderer/VertexArraySpec.js b/Specs/Renderer/VertexArraySpec.js
index d9ec6758e143..e0c9335525da 100644
--- a/Specs/Renderer/VertexArraySpec.js
+++ b/Specs/Renderer/VertexArraySpec.js
@@ -270,7 +270,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
sp = sp.destroy();
va = va.destroy();
@@ -321,7 +321,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
sp = sp.destroy();
va = va.destroy();
@@ -372,7 +372,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
sp = sp.destroy();
va = va.destroy();
@@ -423,7 +423,7 @@ defineSuite([
});
command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
+ expect(context).toReadPixels([255, 255, 255, 255]);
sp = sp.destroy();
va = va.destroy();
diff --git a/Specs/Renderer/loadCubeMapSpec.js b/Specs/Renderer/loadCubeMapSpec.js
index 4968b19082ce..f681ad3af67b 100644
--- a/Specs/Renderer/loadCubeMapSpec.js
+++ b/Specs/Renderer/loadCubeMapSpec.js
@@ -56,7 +56,16 @@ defineSuite([
position : 0
}
});
- sp.allUniforms.u_texture.value = cm;
+ var uniformMap = {
+ direction : undefined,
+
+ u_texture : function() {
+ return cm;
+ },
+ u_direction : function() {
+ return this.direction;
+ }
+ };
var va = new VertexArray({
context : context,
@@ -73,38 +82,39 @@ defineSuite([
var command = new DrawCommand({
primitiveType : PrimitiveType.POINTS,
shaderProgram : sp,
- vertexArray : va
+ vertexArray : va,
+ uniformMap : uniformMap
});
// +X is green
- sp.allUniforms.u_direction.value = new Cartesian3(1, 0, 0);
+ uniformMap.direction = new Cartesian3(1, 0, 0);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ expect(context).toReadPixels([0, 255, 0, 255]);
// -X is blue
- sp.allUniforms.u_direction.value = new Cartesian3(-1, 0, 0);
+ uniformMap.direction = new Cartesian3(-1, 0, 0);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
+ expect(context).toReadPixels([0, 0, 255, 255]);
// +Y is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, 1, 0);
+ uniformMap.direction = new Cartesian3(0, 1, 0);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ expect(context).toReadPixels([0, 255, 0, 255]);
// -Y is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, -1, 0);
+ uniformMap.direction = new Cartesian3(0, -1, 0);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
+ expect(context).toReadPixels([0, 0, 255, 255]);
// +Z is green
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, 1);
+ uniformMap.direction = new Cartesian3(0, 0, 1);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 255, 0, 255]);
+ expect(context).toReadPixels([0, 255, 0, 255]);
// -Z is blue
- sp.allUniforms.u_direction.value = new Cartesian3(0, 0, -1);
+ uniformMap.direction = new Cartesian3(0, 0, -1);
command.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 255, 255]);
+ expect(context).toReadPixels([0, 0, 255, 255]);
sp.destroy();
va.destroy();
diff --git a/Specs/Scene/BillboardCollectionSpec.js b/Specs/Scene/BillboardCollectionSpec.js
index 205b0ed70656..490ee8c0d106 100644
--- a/Specs/Scene/BillboardCollectionSpec.js
+++ b/Specs/Scene/BillboardCollectionSpec.js
@@ -129,7 +129,7 @@ defineSuite([
it('can add and remove before first update.', function() {
var b = billboards.add();
billboards.remove(b);
- expect(scene.renderForSpecs()).toBeDefined();
+ scene.renderForSpecs();
});
it('explicitly constructs a billboard', function() {
@@ -266,10 +266,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(1e6, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('disables billboard scaleByDistance', function() {
@@ -304,10 +304,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders billboard with translucencyByDistance', function() {
@@ -318,10 +318,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders billboard with pixelOffsetScaleByDistance', function() {
@@ -333,10 +333,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('throws scaleByDistance with nearDistance === farDistance', function() {
@@ -422,13 +422,13 @@ defineSuite([
});
camera.position = new Cartesian3(200.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
camera.position = new Cartesian3(50.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(5.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('throws new billboard with invalid distanceDisplayCondition (near >= far)', function() {
@@ -609,7 +609,7 @@ defineSuite([
});
it('does not render when constructed', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('modifies and removes a billboard, then renders', function() {
@@ -622,11 +622,11 @@ defineSuite([
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
b1.scale = 2.0;
billboards.remove(b1);
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders a green billboard', function() {
@@ -635,7 +635,7 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('adds and renders a billboard', function() {
@@ -644,14 +644,14 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.add({
position : new Cartesian3(1.0, 0.0, 0.0), // Closer to camera
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('removes and renders a billboard', function() {
@@ -664,10 +664,10 @@ defineSuite([
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
billboards.remove(blueBillboard);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('removes all billboards and renders', function() {
@@ -676,10 +676,10 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('removes all billboards, adds a billboard, and renders', function() {
@@ -688,7 +688,7 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.removeAll();
billboards.add({
@@ -696,7 +696,7 @@ defineSuite([
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders with a different texture atlas', function() {
@@ -705,11 +705,11 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.textureAtlas = new TextureAtlas({ context : scene.context });
b.image = blueImage;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using billboard show property', function() {
@@ -723,12 +723,12 @@ defineSuite([
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
greenBillboard.show = false;
blueBillboard.show = true;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using billboard position property', function() {
@@ -737,13 +737,13 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
b.position = new Cartesian3(20.0, 0.0, 0.0); // Behind camera
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
b.position = new Cartesian3(1.0, 0.0, 0.0); // Back in front of camera
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard scale property', function() {
@@ -752,13 +752,13 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
b.scale = 0.0;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
b.scale = 2.0;
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard image property', function() {
@@ -767,10 +767,10 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
b.image = largeBlueImage;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using billboard setImage function', function() {
@@ -779,10 +779,10 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
b.setImage(largeBlueImage.src, largeBlueImage);
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using billboard setImageSubRegion function', function() {
@@ -791,11 +791,11 @@ defineSuite([
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.textureAtlas.addImage(largeBlueImage.src, largeBlueImage);
b.setImageSubRegion(largeBlueImage.src, new BoundingRectangle(5.0, 5.0, 1.0, 1.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using billboard color property', function() {
@@ -804,14 +804,14 @@ defineSuite([
image : whiteImage
});
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
b.color = new Color(1.0, 0.0, 1.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([255, 0, 255, 255]);
+ expect(scene).toRender([255, 0, 255, 255]);
// Update a second time since it goes through a different vertex array update path
b.color = new Color(0.0, 1.0, 0.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard rotation property', function() {
@@ -821,7 +821,7 @@ defineSuite([
});
b.rotation = CesiumMath.PI_OVER_TWO;
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard aligned axis property', function() {
@@ -831,7 +831,7 @@ defineSuite([
});
b.alignedAxis = Cartesian3.UNIT_X;
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard custom width property', function() {
@@ -841,7 +841,7 @@ defineSuite([
});
b.width = 300.0;
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using billboard custom height property', function() {
@@ -851,7 +851,7 @@ defineSuite([
});
b.height = 300.0;
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders bounding volume with debugShowBoundingVolume', function() {
@@ -862,7 +862,7 @@ defineSuite([
});
billboards.debugShowBoundingVolume = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders billboards when instancing is disabled', function() {
@@ -870,25 +870,25 @@ defineSuite([
var instancedArrays = context._instancedArrays;
context._instancedArrays = undefined;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
var b1 = billboards.add({
position : Cartesian3.ZERO,
image : greenImage
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
var b2 = billboards.add({
position : new Cartesian3(1.0, 0.0, 0.0), // Closer to camera
image : largeBlueImage
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
billboards.remove(b2);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.remove(b1);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
context._instancedArrays = instancedArrays;
});
@@ -903,17 +903,17 @@ defineSuite([
}
// First render - default billboard color is white.
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
billboards.get(3).color = new Color(0.0, 1.0, 0.0, 1.0);
// Second render - billboard is green
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
billboards.get(3).color = new Color(1.0, 0.0, 0.0, 1.0);
// Third render - update goes through a different vertex array update path
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
});
it('renders more than 16K billboards', function() {
@@ -932,7 +932,7 @@ defineSuite([
image : whiteImage
});
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
});
it('is picked', function() {
@@ -942,9 +942,10 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(b);
+ expect(result.id).toEqual('id');
+ });
});
it('can change pick id', function() {
@@ -954,15 +955,17 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(b);
+ expect(result.id).toEqual('id');
+ });
b.id = 'id2';
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
- expect(pick.id).toEqual('id2');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(b);
+ expect(result.id).toEqual('id2');
+ });
});
it('is not picked', function() {
@@ -972,8 +975,7 @@ defineSuite([
image : whiteImage
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a billboard using scaleByDistance', function() {
@@ -985,15 +987,13 @@ defineSuite([
var scaleByDistance = new NearFarScalar(1.0, 4.0, 3.0e9, 2.0);
b.scaleByDistance = scaleByDistance;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
+ expect(scene).toPickPrimitive(b);
scaleByDistance.nearValue = 0.0;
scaleByDistance.farValue = 0.0;
b.scaleByDistance = scaleByDistance;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a billboard using translucencyByDistance', function() {
@@ -1005,15 +1005,13 @@ defineSuite([
var translucency = new NearFarScalar(1.0, 0.9, 3.0e9, 0.8);
b.translucencyByDistance = translucency;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
+ expect(scene).toPickPrimitive(b);
translucency.nearValue = 0.0;
translucency.farValue = 0.0;
b.translucencyByDistance = translucency;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a billboard using pixelOffsetScaleByDistance', function() {
@@ -1026,15 +1024,13 @@ defineSuite([
var pixelOffsetScale = new NearFarScalar(1.0, 0.0, 3.0e9, 0.0);
b.pixelOffsetScaleByDistance = pixelOffsetScale;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
+ expect(scene).toPickPrimitive(b);
pixelOffsetScale.nearValue = 10.0;
pixelOffsetScale.farValue = 10.0;
b.pixelOffsetScaleByDistance = pixelOffsetScale;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('can pick a billboard using the rotation property', function() {
@@ -1044,8 +1040,7 @@ defineSuite([
});
b.rotation = CesiumMath.PI_OVER_TWO;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
+ expect(scene).toPickPrimitive(b);
});
it('can pick a billboard using the aligned axis property', function() {
@@ -1055,8 +1050,7 @@ defineSuite([
});
b.alignedAxis = Cartesian3.UNIT_X;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(b);
+ expect(scene).toPickPrimitive(b);
});
it('computes screen space position', function() {
@@ -1463,7 +1457,7 @@ defineSuite([
return pollToPromise(function() {
return one.ready;
}).then(function() {
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
});
@@ -1526,12 +1520,12 @@ defineSuite([
return pollToPromise(function() {
return one.ready;
}).then(function() {
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
one.image = './Data/Images/Green2x2.png';
expect(one.ready).toEqual(true);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
});
@@ -1544,7 +1538,7 @@ defineSuite([
// the image property will be an autogenerated id if not provided
expect(one.image).toBeDefined();
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('can create a billboard using a function and id', function() {
@@ -1557,7 +1551,7 @@ defineSuite([
// the image property will be an autogenerated id if not provided
expect(one.image).toEqual('Foo');
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('can create a billboard using another billboard image', function() {
@@ -1579,7 +1573,7 @@ defineSuite([
expect(two.image).toEqual(one.image);
expect(createImage.calls.count()).toEqual(1);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('can create a billboard using a subregion of an image', function() {
@@ -1595,7 +1589,7 @@ defineSuite([
return pollToPromise(function() {
return one.ready;
}).then(function() {
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
});
});
@@ -1645,7 +1639,7 @@ defineSuite([
var iterations = 10;
function renderAndCheck() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
if (iterations > 0) {
--iterations;
@@ -1685,7 +1679,7 @@ defineSuite([
var iterations = 10;
function renderAndCheck() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
if (iterations > 0) {
--iterations;
@@ -1716,7 +1710,7 @@ defineSuite([
var iterations = 10;
function renderAndCheck() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
if (iterations > 0) {
--iterations;
diff --git a/Specs/Scene/CameraEventAggregatorSpec.js b/Specs/Scene/CameraEventAggregatorSpec.js
index 17ee047fdf8d..6fa4f3f7e23c 100644
--- a/Specs/Scene/CameraEventAggregatorSpec.js
+++ b/Specs/Scene/CameraEventAggregatorSpec.js
@@ -7,7 +7,6 @@ defineSuite([
'Core/KeyboardEventModifier',
'Scene/CameraEventType',
'Specs/createCanvas',
- 'Specs/destroyCanvas',
'Specs/DomEventSimulator'
], function(
CameraEventAggregator,
@@ -17,7 +16,6 @@ defineSuite([
KeyboardEventModifier,
CameraEventType,
createCanvas,
- destroyCanvas,
DomEventSimulator) {
'use strict';
@@ -31,7 +29,7 @@ defineSuite([
});
afterAll(function() {
- destroyCanvas(canvas);
+ document.body.removeChild(canvas);
});
beforeEach(function() {
diff --git a/Specs/Scene/DebugAppearanceSpec.js b/Specs/Scene/DebugAppearanceSpec.js
index 5b2fda8b3ef9..f8250ef0759d 100644
--- a/Specs/Scene/DebugAppearanceSpec.js
+++ b/Specs/Scene/DebugAppearanceSpec.js
@@ -196,10 +196,10 @@ defineSuite([
compressVertices : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders bitangent', function() {
@@ -218,10 +218,10 @@ defineSuite([
compressVertices : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders tangent', function() {
@@ -240,10 +240,10 @@ defineSuite([
compressVertices : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders st', function() {
@@ -261,10 +261,10 @@ defineSuite([
compressVertices : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders float', function() {
@@ -286,10 +286,10 @@ defineSuite([
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders vec2', function() {
@@ -311,10 +311,10 @@ defineSuite([
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders vec3', function() {
@@ -336,10 +336,10 @@ defineSuite([
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders vec4', function() {
@@ -360,10 +360,10 @@ defineSuite([
}),
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Scene/DebugCameraPrimitiveSpec.js b/Specs/Scene/DebugCameraPrimitiveSpec.js
index 2d3d9b00c5d9..9f4da888c2e3 100644
--- a/Specs/Scene/DebugCameraPrimitiveSpec.js
+++ b/Specs/Scene/DebugCameraPrimitiveSpec.js
@@ -70,7 +70,7 @@ defineSuite([
scene.primitives.add(new DebugCameraPrimitive({
camera : camera
}));
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render when show is false', function() {
@@ -78,7 +78,7 @@ defineSuite([
camera : camera,
show : false
}));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('updates when underlying camera changes', function() {
@@ -108,9 +108,10 @@ defineSuite([
id : 'id'
}));
- var pick = scene.pickForSpecs();
- expect(pick.primitive).toBe(p);
- expect(pick.id).toBe('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toBe(p);
+ expect(result.id).toBe('id');
+ });
});
it('isDestroyed', function() {
diff --git a/Specs/Scene/DebugModelMatrixPrimitiveSpec.js b/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
index 7210ab1fc002..2364fab20b13 100644
--- a/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
+++ b/Specs/Scene/DebugModelMatrixPrimitiveSpec.js
@@ -57,18 +57,18 @@ defineSuite([
it('renders', function() {
var p = scene.primitives.add(new DebugModelMatrixPrimitive());
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
// Update and render again
p.length = 100.0;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render when show is false', function() {
scene.primitives.add(new DebugModelMatrixPrimitive({
show : false
}));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('is picked', function() {
@@ -76,9 +76,10 @@ defineSuite([
id : 'id'
}));
- var pick = scene.pickForSpecs();
- expect(pick.primitive).toBe(p);
- expect(pick.id).toBe('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toBe(p);
+ expect(result.id).toBe('id');
+ });
});
it('isDestroyed', function() {
diff --git a/Specs/Scene/DeviceOrientationCameraControllerSpec.js b/Specs/Scene/DeviceOrientationCameraControllerSpec.js
index e639ba80cb04..8e6c54d19dc1 100644
--- a/Specs/Scene/DeviceOrientationCameraControllerSpec.js
+++ b/Specs/Scene/DeviceOrientationCameraControllerSpec.js
@@ -5,7 +5,6 @@ defineSuite([
'Core/Math',
'Specs/createCamera',
'Specs/createCanvas',
- 'Specs/destroyCanvas',
'Specs/DomEventSimulator'
], function(
DeviceOrientationCameraController,
@@ -13,7 +12,6 @@ defineSuite([
CesiumMath,
createCamera,
createCanvas,
- destroyCanvas,
DomEventSimulator) {
'use strict';
@@ -32,7 +30,7 @@ defineSuite([
});
afterAll(function() {
- destroyCanvas(canvas);
+ document.body.removeChild(canvas);
});
beforeEach(function() {
diff --git a/Specs/Scene/EllipsoidPrimitiveSpec.js b/Specs/Scene/EllipsoidPrimitiveSpec.js
index f0927d332a54..cf4b0cc44fb8 100644
--- a/Specs/Scene/EllipsoidPrimitiveSpec.js
+++ b/Specs/Scene/EllipsoidPrimitiveSpec.js
@@ -76,20 +76,20 @@ defineSuite([
it('renders with the default material', function() {
ellipsoid.radii = new Cartesian3(1.0, 1.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(ellipsoid);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders with a custom modelMatrix', function() {
ellipsoid.radii = new Cartesian3(0.1, 0.1, 0.1);
ellipsoid.modelMatrix = Matrix4.fromScale(new Cartesian3(10.0, 10.0, 10.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(ellipsoid);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders two with a vertex array cache hit', function() {
@@ -97,17 +97,20 @@ defineSuite([
var ellipsoid2 = new EllipsoidPrimitive();
ellipsoid2.radii = new Cartesian3(1.0, 1.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(ellipsoid);
- var result = scene.renderForSpecs();
- expect(result).not.toEqual([0, 0, 0, 255]);
+ var result;
+ expect(scene).toRenderAndCall(function(rgba) {
+ result = rgba;
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ });
- expect(scene.renderForSpecs()).toEqual(result);
+ expect(scene).toRender(result);
scene.primitives.add(ellipsoid2);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
- expect(scene.renderForSpecs()).not.toEqual(result);
+ expect(scene).notToRender([0, 0, 0, 255]);
+ expect(scene).notToRender(result);
ellipsoid2.destroy();
});
@@ -124,28 +127,28 @@ defineSuite([
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X, new Cartesian3());
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render when show is false', function() {
ellipsoid.radii = new Cartesian3(1.0, 1.0, 1.0);
ellipsoid.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('does not render without radii', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('does not render when not in view due to center', function() {
ellipsoid.radii = new Cartesian3(1.0, 1.0, 1.0);
ellipsoid.center = new Cartesian3(10.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(ellipsoid);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('is picked', function() {
@@ -154,9 +157,10 @@ defineSuite([
scene.primitives.add(ellipsoid);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(ellipsoid);
- expect(pickedObject.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(ellipsoid);
+ expect(result.id).toEqual('id');
+ });
});
it('is not picked (show === false)', function() {
@@ -165,7 +169,7 @@ defineSuite([
scene.primitives.add(ellipsoid);
- expect(scene.pickForSpecs()).not.toBeDefined();
+ expect(scene).notToPick();
});
it('is not picked (alpha === 0.0)', function() {
@@ -174,7 +178,7 @@ defineSuite([
scene.primitives.add(ellipsoid);
- expect(scene.pickForSpecs()).not.toBeDefined();
+ expect(scene).notToPick();
});
it('isDestroyed', function() {
diff --git a/Specs/Scene/EllipsoidSurfaceAppearanceSpec.js b/Specs/Scene/EllipsoidSurfaceAppearanceSpec.js
index eb3815022919..358909a5dab6 100644
--- a/Specs/Scene/EllipsoidSurfaceAppearanceSpec.js
+++ b/Specs/Scene/EllipsoidSurfaceAppearanceSpec.js
@@ -77,10 +77,10 @@ defineSuite([
});
primitive.appearance = new EllipsoidSurfaceAppearance();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Scene/GeometryRenderingSpec.js b/Specs/Scene/GeometryRenderingSpec.js
index 9b1e7effa501..a0052eb22384 100644
--- a/Specs/Scene/GeometryRenderingSpec.js
+++ b/Specs/Scene/GeometryRenderingSpec.js
@@ -119,14 +119,14 @@ defineSuite([
scene.camera.update(scene.mode);
scene.camera.viewBoundingSphere(geometry.boundingSphereWC);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
if (typeof afterView === 'function') {
afterView();
}
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
}
function renderCV(instance, afterView, appearance) {
@@ -147,13 +147,13 @@ defineSuite([
scene.camera.update(scene.mode);
scene.camera.viewBoundingSphere(geometry.boundingSphereWC);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
if (typeof afterView === 'function') {
afterView();
}
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
}
function render2D(instance, appearance) {
@@ -174,10 +174,10 @@ defineSuite([
scene.camera.update(scene.mode);
scene.camera.viewBoundingSphere(geometry.boundingSphereWC);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
}
function pickGeometry(instance, afterView, appearance) {
@@ -203,9 +203,10 @@ defineSuite([
afterView();
}
- var pickObject = scene.pickForSpecs();
- expect(pickObject.primitive).toEqual(primitive);
- expect(pickObject.id).toEqual(instance.id);
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(primitive);
+ expect(result.id).toEqual(instance.id);
+ });
}
function renderAsync(instance, afterView, appearance) {
@@ -225,7 +226,7 @@ defineSuite([
scene.camera.update(scene.mode);
scene.camera.viewBoundingSphere(geometry.boundingSphereWC);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
if (typeof afterView === 'function') {
@@ -237,7 +238,7 @@ defineSuite([
scene.renderForSpecs();
return primitive.ready;
}).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}
diff --git a/Specs/Scene/GlobeSpec.js b/Specs/Scene/GlobeSpec.js
index 78de4c934908..d0006c09f088 100644
--- a/Specs/Scene/GlobeSpec.js
+++ b/Specs/Scene/GlobeSpec.js
@@ -79,9 +79,9 @@ defineSuite([
return updateUntilDone(globe).then(function() {
scene.globe.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.globe.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
@@ -96,9 +96,9 @@ defineSuite([
return updateUntilDone(globe).then(function() {
scene.globe.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.globe.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
@@ -143,9 +143,9 @@ defineSuite([
return updateUntilDone(globe).then(function() {
scene.globe.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.globe.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
});
diff --git a/Specs/Scene/GlobeSurfaceTileProviderSpec.js b/Specs/Scene/GlobeSurfaceTileProviderSpec.js
index 54091fac5430..9c21718503ad 100644
--- a/Specs/Scene/GlobeSurfaceTileProviderSpec.js
+++ b/Specs/Scene/GlobeSurfaceTileProviderSpec.js
@@ -286,7 +286,7 @@ defineSuite([
}, 'WebGL');
it('renders in 2D geographic', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -295,12 +295,12 @@ defineSuite([
switchViewMode(SceneMode.SCENE2D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
it('renders in 2D web mercator', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -309,12 +309,12 @@ defineSuite([
switchViewMode(SceneMode.SCENE2D, new WebMercatorProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
it('renders in Columbus View geographic', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -323,12 +323,12 @@ defineSuite([
switchViewMode(SceneMode.COLUMBUS_VIEW, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
it('renders in Columbus View web mercator', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -337,12 +337,12 @@ defineSuite([
switchViewMode(SceneMode.COLUMBUS_VIEW, new WebMercatorProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 128, 255]);
+ expect(scene).notToRender([0, 0, 128, 255]);
});
});
it('renders in 3D', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -351,12 +351,12 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
it('renders in 3D (2)', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -365,13 +365,13 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
describe('fog', function() {
it('culls tiles in full fog', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
}));
@@ -380,20 +380,20 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
scene.fog.enabled = true;
scene.fog.density = 1.0;
scene.fog.screenSpaceErrorFactor = 0.0;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.fog = oldFog;
});
});
it('culls tiles because of increased SSE', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
}));
@@ -402,17 +402,20 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
scene.fog.enabled = true;
scene.fog.density = 0.001;
scene.fog.screenSpaceErrorFactor = 0.0;
- var result = scene.renderForSpecs();
- expect(result).not.toEqual([0, 0, 0, 255]);
+ var result;
+ expect(scene).toRenderAndCall(function(rgba) {
+ result = rgba;
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ });
scene.fog.screenSpaceErrorFactor = 10000.0;
- expect(scene.renderForSpecs()).not.toEqual(result);
+ expect(scene).notToRender(result);
scene.fog = oldFog;
});
@@ -420,15 +423,13 @@ defineSuite([
});
it('can change baseColor', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.globe.baseColor = Color.RED;
scene.fog.enabled = false;
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- var result = scene.renderForSpecs();
- expect(result).not.toEqual([0, 0, 0, 255]);
- expect(result).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
});
});
@@ -439,18 +440,18 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
switchViewMode(SceneMode.COLUMBUS_VIEW, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
});
it('renders even if imagery root tiles fail to load', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
var providerWithInvalidRootTiles = new WebMapServiceImageryProvider({
url : '/invalid',
@@ -461,12 +462,12 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
});
it('passes layer adjustment values as uniforms', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
var layer = scene.imageryLayers.addImageryProvider(new SingleTileImageryProvider({
url : 'Data/Images/Red16x16.png'
@@ -483,7 +484,7 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var tileCommandCount = 0;
var commandList = scene.frameState.commandList;
@@ -521,7 +522,7 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var tileCommandCount = 0;
var commandList = scene.frameState.commandList;
@@ -553,7 +554,7 @@ defineSuite([
switchViewMode(SceneMode.SCENE3D, new GeographicProjection(Ellipsoid.WGS84));
return updateUntilDone(scene.globe).then(function() {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var renderStateWithAlphaBlending = RenderState.fromCache({
blending : BlendingState.ALPHA_BLEND
diff --git a/Specs/Scene/GroundPrimitiveSpec.js b/Specs/Scene/GroundPrimitiveSpec.js
index 35201b444668..73126fabedd3 100644
--- a/Specs/Scene/GroundPrimitiveSpec.js
+++ b/Specs/Scene/GroundPrimitiveSpec.js
@@ -301,13 +301,13 @@ defineSuite([
scene.camera.setView({ destination : rectangle });
scene.groundPrimitives.add(depthPrimitive);
- var pixels = scene.renderForSpecs();
- expect(pixels).not.toEqual([0, 0, 0, 255]);
- expect(pixels[0]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ expect(rgba[0]).toEqual(0);
+ });
scene.groundPrimitives.add(primitive);
- pixels = scene.renderForSpecs();
- expect(pixels).toEqual(color);
+ expect(scene).toRender(color);
}
it('renders in 3D', function() {
@@ -398,11 +398,12 @@ defineSuite([
scene.groundPrimitives.add(primitive);
scene.camera.setView({ destination : rectangle });
- var pixels = scene.renderForSpecs();
- expect(pixels[1]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[1]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[2]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[2]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[3]).toEqual(255);
+ });
});
it('renders shadow volume with debugShowShadowVolume', function() {
@@ -418,11 +419,12 @@ defineSuite([
scene.groundPrimitives.add(primitive);
scene.camera.setView({ destination : rectangle });
- var pixels = scene.renderForSpecs();
- expect(pixels[1]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[1]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[2]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[2]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[3]).toEqual(255);
+ });
});
it('get per instance attributes', function() {
@@ -491,6 +493,10 @@ defineSuite([
});
it('renders with distance display condition per instance attribute', function() {
+ if (!GroundPrimitive.isSupported(scene)) {
+ return;
+ }
+
var near = 10000.0;
var far = 1000000.0;
var rect = Rectangle.fromDegrees(-1.0, -1.0, 1.0, 1.0);
@@ -545,13 +551,13 @@ defineSuite([
var radius = boundingSphere.radius;
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius));
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + near + 1.0));
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 255, 255]);
+ expect(scene).notToRender([0, 0, 255, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + far + 1.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('get bounding sphere from per instance attribute', function() {
@@ -599,8 +605,9 @@ defineSuite([
verifyGroundPrimitiveRender(primitive, rectColor);
- var pickObject = scene.pickForSpecs();
- expect(pickObject.id).toEqual('rectangle');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.id).toEqual('rectangle');
+ });
});
it('does not pick when allowPicking is false', function() {
@@ -616,8 +623,7 @@ defineSuite([
verifyGroundPrimitiveRender(primitive, rectColor);
- var pickObject = scene.pickForSpecs();
- expect(pickObject).not.toBeDefined();
+ expect(scene).notToPick();
});
it('internally invalid asynchronous geometry resolves promise and sets ready', function() {
diff --git a/Specs/Scene/LabelCollectionSpec.js b/Specs/Scene/LabelCollectionSpec.js
index 50abe11e756e..694e42eaf079 100644
--- a/Specs/Scene/LabelCollectionSpec.js
+++ b/Specs/Scene/LabelCollectionSpec.js
@@ -309,7 +309,7 @@ defineSuite([
});
it('does not render when constructed', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('can render after modifying and removing a label', function() {
@@ -326,12 +326,14 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
labelOne.scale = 2.0;
labels.remove(labelOne);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('can render a label', function() {
@@ -342,7 +344,9 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('renders in multiple passes', function() {
@@ -379,10 +383,11 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- var actual = scene.renderForSpecs();
- expect(actual[0]).toBeGreaterThan(200);
- expect(actual[1]).toBeGreaterThan(200);
- expect(actual[2]).toBeGreaterThan(200);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(200);
+ expect(rgba[1]).toBeGreaterThan(200);
+ expect(rgba[2]).toBeGreaterThan(200);
+ });
labels.add({
position : new Cartesian3(1.0, 0.0, 0.0), // Closer to camera
@@ -397,10 +402,11 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- actual = scene.renderForSpecs();
- expect(actual[0]).toBeGreaterThan(200);
- expect(actual[1]).toBeLessThan(10);
- expect(actual[2]).toBeLessThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(200);
+ expect(rgba[1]).toBeLessThan(10);
+ expect(rgba[2]).toBeLessThan(10);
+ });
});
it('can render after removing a label', function() {
@@ -411,10 +417,12 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
labels.remove(label);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('can render after removing and adding a label', function() {
@@ -425,7 +433,9 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
labels.remove(label);
labels.add({
@@ -435,7 +445,9 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('can render after removing all labels', function() {
@@ -446,10 +458,12 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
labels.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('can render after removing all labels and adding a label', function() {
@@ -460,7 +474,9 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
labels.removeAll();
labels.add({
@@ -470,7 +486,9 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('can render a label background', function() {
@@ -483,10 +501,10 @@ defineSuite([
backgroundColor : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
labels.remove(label);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('does not render labels with show set to false', function() {
@@ -497,13 +515,17 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
label.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
label.show = true;
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('does not render label background with show set to false', function() {
@@ -516,13 +538,13 @@ defineSuite([
backgroundColor : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
label.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
label.show = true;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('does not render labels that are behind the viewer', function() {
@@ -533,10 +555,12 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
label.position = Cartesian3.ZERO; // Back in front of camera
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('does not render labels with a scale of zero', function() {
@@ -548,10 +572,12 @@ defineSuite([
});
label.scale = 0.0;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
label.scale = 2.0;
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
});
it('renders label with translucencyByDistance', function() {
@@ -564,10 +590,12 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders label with pixelOffsetScaleByDistance', function() {
@@ -581,10 +609,12 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(10);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(10);
+ });
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders label with distanceDisplayCondition', function() {
@@ -597,15 +627,17 @@ defineSuite([
});
camera.position = new Cartesian3(200.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
camera.position = new Cartesian3(50.0, 0.0, 0.0);
- expect(scene.renderForSpecs()[0]).toBeGreaterThan(200);
- expect(scene.renderForSpecs()[1]).toBeGreaterThan(200);
- expect(scene.renderForSpecs()[2]).toBeGreaterThan(200);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(200);
+ expect(rgba[1]).toBeGreaterThan(200);
+ expect(rgba[2]).toBeGreaterThan(200);
+ });
camera.position = new Cartesian3(5.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('throws new label with invalid distanceDisplayCondition (near >= far)', function() {
@@ -634,9 +666,10 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(label);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(label);
+ expect(result.id).toEqual('id');
+ });
});
it('can change pick id', function() {
@@ -648,15 +681,17 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(label);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(label);
+ expect(result.id).toEqual('id');
+ });
label.id = 'id2';
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(label);
- expect(pick.id).toEqual('id2');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(label);
+ expect(result.id).toEqual('id2');
+ });
});
it('does not pick a label with show set to false', function() {
@@ -668,8 +703,7 @@ defineSuite([
verticalOrigin : VerticalOrigin.CENTER
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a label using translucencyByDistance', function() {
@@ -683,15 +717,13 @@ defineSuite([
var translucency = new NearFarScalar(1.0, 0.9, 3.0e9, 0.8);
label.translucencyByDistance = translucency;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(label);
+ expect(scene).toPickPrimitive(label);
translucency.nearValue = 0.0;
translucency.farValue = 0.0;
label.translucencyByDistance = translucency;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a label using pixelOffsetScaleByDistance', function() {
@@ -706,15 +738,13 @@ defineSuite([
var pixelOffsetScale = new NearFarScalar(1.0, 0.0, 3.0e9, 0.0);
label.pixelOffsetScaleByDistance = pixelOffsetScale;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(label);
+ expect(scene).toPickPrimitive(label);
pixelOffsetScale.nearValue = 10.0;
pixelOffsetScale.farValue = 10.0;
label.pixelOffsetScaleByDistance = pixelOffsetScale;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('throws when calling get without an index', function() {
diff --git a/Specs/Scene/MaterialAppearanceSpec.js b/Specs/Scene/MaterialAppearanceSpec.js
index d2d535827b5a..9a26687dafb1 100644
--- a/Specs/Scene/MaterialAppearanceSpec.js
+++ b/Specs/Scene/MaterialAppearanceSpec.js
@@ -87,10 +87,10 @@ defineSuite([
material : Material.fromType(Material.DotType)
});
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
it('renders textured', function() {
@@ -104,10 +104,10 @@ defineSuite([
})
});
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
it('renders all', function() {
@@ -119,10 +119,10 @@ defineSuite([
material : Material.fromType(Material.NormalMapType)
});
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
}, 'WebGL');
diff --git a/Specs/Scene/MaterialSpec.js b/Specs/Scene/MaterialSpec.js
index 0be40157f399..dd06c79b8d5c 100644
--- a/Specs/Scene/MaterialSpec.js
+++ b/Specs/Scene/MaterialSpec.js
@@ -4,6 +4,7 @@ defineSuite([
'Core/Cartesian3',
'Core/Color',
'Core/defaultValue',
+ 'Core/defined',
'Core/Ellipsoid',
'Core/GeometryInstance',
'Core/Rectangle',
@@ -18,6 +19,7 @@ defineSuite([
Cartesian3,
Color,
defaultValue,
+ defined,
Ellipsoid,
GeometryInstance,
Rectangle,
@@ -83,26 +85,32 @@ defineSuite([
polylines = polylines && polylines.destroy();
});
- function renderMaterial(material, ignoreBackground) {
+ function renderMaterial(material, ignoreBackground, callback) {
ignoreBackground = defaultValue(ignoreBackground, false);
polygon.appearance.material = material;
if (!ignoreBackground) {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
}
scene.primitives.add(polygon);
- var result = scene.renderForSpecs();
- expect(result).not.toEqual(backgroundColor);
- return result;
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ if (defined(callback)) {
+ callback(rgba);
+ }
+ });
}
function renderPolylineMaterial(material) {
polyline.material = material;
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.primitives.add(polylines);
- var result = scene.renderForSpecs();
- expect(result).not.toEqual(backgroundColor);
+ var result;
+ expect(scene).toRenderAndCall(function(rgba) {
+ result = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
return result;
}
@@ -489,8 +497,9 @@ defineSuite([
color : new Color(0.0, 1.0, 0.0, 1.0)
});
- var pixel = renderMaterial(material1);
- expect(pixel).toEqual([0, 255, 0, 255]);
+ renderMaterial(material1, false, function(rgba) {
+ expect(rgba).toEqual([0, 255, 0, 255]);
+ });
});
it('create multiple materials from the same type', function() {
@@ -504,10 +513,12 @@ defineSuite([
expect(material1.shaderSource).toEqual(material2.shaderSource);
- var pixel = renderMaterial(material2);
- expect(pixel).toEqual([255, 0, 0, 255]);
- pixel = renderMaterial(material1, true);
- expect(pixel).toEqual([0, 255, 0, 255]);
+ renderMaterial(material2, false, function(rgba) {
+ expect(rgba).toEqual([255, 0, 0, 255]);
+ });
+ renderMaterial(material1, true, function(rgba) {
+ expect(rgba).toEqual([0, 255, 0, 255]);
+ });
});
it('create material with sub-materials of the same type', function() {
@@ -533,8 +544,9 @@ defineSuite([
}
});
- var pixel = renderMaterial(material);
- expect(pixel).toEqual([0, 255, 255, 255]);
+ renderMaterial(material, false, function(rgba) {
+ expect(rgba).toEqual([0, 255, 255, 255]);
+ });
});
it('throws with source and components in same template', function () {
diff --git a/Specs/Scene/ModelSpec.js b/Specs/Scene/ModelSpec.js
index 2a460f4b94cb..f89a97cb24ee 100644
--- a/Specs/Scene/ModelSpec.js
+++ b/Specs/Scene/ModelSpec.js
@@ -8,6 +8,7 @@ defineSuite([
'Core/clone',
'Core/Color',
'Core/combine',
+ 'Core/defaultValue',
'Core/defined',
'Core/defineProperties',
'Core/DistanceDisplayCondition',
@@ -42,6 +43,7 @@ defineSuite([
clone,
Color,
combine,
+ defaultValue,
defined,
defineProperties,
DistanceDisplayCondition,
@@ -177,10 +179,11 @@ defineSuite([
}
function loadModelJson(gltf, options) {
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
options = combine(options, {
modelMatrix : Transforms.eastNorthUpToFixedFrame(Cartesian3.fromDegrees(0.0, 0.0, 100.0)),
gltf : gltf,
- show : false
+ show : defaultValue(options.show, false)
});
var model = primitives.add(new Model(options));
@@ -197,13 +200,11 @@ defineSuite([
function verifyRender(model) {
expect(model.ready).toBe(true);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
model.show = true;
model.zoomTo();
- var pixelColor = scene.renderForSpecs();
- expect(pixelColor).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
model.show = false;
- return pixelColor;
}
it('fromGltf throws without options', function() {
@@ -413,7 +414,7 @@ defineSuite([
});
it('renders in wireframe', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
texturedBoxModel.show = true;
texturedBoxModel.debugWireframe = true;
@@ -431,7 +432,7 @@ defineSuite([
});
it('renders with distance display condition', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
var center = Matrix4.getTranslation(texturedBoxModel.modelMatrix, new Cartesian3());
var near = 10.0;
@@ -798,7 +799,7 @@ defineSuite([
});
it('renders cesiumAir with per-node show (root)', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
var commands = cesiumAirModel._nodeCommands;
var i;
@@ -808,7 +809,7 @@ defineSuite([
cesiumAirModel.zoomTo();
cesiumAirModel.getNode('Cesium_Air').show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
length = commands.length;
for (i = 0; i < length; ++i) {
@@ -816,7 +817,7 @@ defineSuite([
}
cesiumAirModel.getNode('Cesium_Air').show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
length = commands.length;
for (i = 0; i < length; ++i) {
@@ -868,11 +869,12 @@ defineSuite([
cesiumAirModel.show = true;
cesiumAirModel.zoomTo();
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(cesiumAirModel);
- expect(pick.id).toEqual(cesiumAirUrl);
- expect(pick.node).toBeDefined();
- expect(pick.mesh).toBeDefined();
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(cesiumAirModel);
+ expect(result.id).toEqual(cesiumAirUrl);
+ expect(result.node).toBeDefined();
+ expect(result.mesh).toBeDefined();
+ });
cesiumAirModel.show = false;
});
@@ -888,9 +890,10 @@ defineSuite([
cesiumAirModel.show = true;
cesiumAirModel.zoomTo();
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(cesiumAirModel);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(cesiumAirModel);
+ expect(result.id).toEqual('id');
+ });
cesiumAirModel.id = oldId;
cesiumAirModel.show = false;
@@ -899,8 +902,7 @@ defineSuite([
it('cesiumAir is not picked (show === false)', function() {
cesiumAirModel.zoomTo();
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
///////////////////////////////////////////////////////////////////////////
@@ -1256,10 +1258,16 @@ defineSuite([
for (var i = 1; i < 4; ++i) {
var t = JulianDate.addSeconds(time, i, new JulianDate());
- expect(scene.renderForSpecs(t)).toEqual([0, 0, 0, 255]);
+ expect({
+ scene : scene,
+ time : t
+ }).toRender([0, 0, 0, 255]);
m.show = true;
- expect(scene.renderForSpecs(t)).not.toEqual([0, 0, 0, 255]);
+ expect({
+ scene : scene,
+ time : t
+ }).notToRender([0, 0, 0, 255]);
m.show = false;
expect(node.matrix).not.toEqual(previousMatrix);
@@ -1294,10 +1302,16 @@ defineSuite([
for (var i = 0; i < 6; ++i) {
var t = JulianDate.addSeconds(time, 0.25 * i, new JulianDate());
- expect(scene.renderForSpecs(t)).toEqual([0, 0, 0, 255]);
+ expect({
+ scene : scene,
+ time : t
+ }).toRender([0, 0, 0, 255]);
riggedFigureModel.show = true;
- expect(scene.renderForSpecs(t)).not.toEqual([0, 0, 0, 255]);
+ expect({
+ scene : scene,
+ time : t
+ }).notToRender([0, 0, 0, 255]);
riggedFigureModel.show = false;
}
@@ -1568,10 +1582,17 @@ defineSuite([
it('Loads with incrementallyLoadTextures set to true', function() {
return loadModelJson(texturedBoxModel.gltf, {
- incrementallyLoadTextures : true
+ incrementallyLoadTextures : true,
+ show : true
}).then(function(m) {
// Get the rendered color of the model before textures are loaded
- var loadedColor = verifyRender(m);
+ var loadedColor;
+
+ m.zoomTo();
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ loadedColor = rgba;
+ });
pollToPromise(function() {
// Render scene to progressively load textures
@@ -1579,8 +1600,7 @@ defineSuite([
// Textures have finished loading
return (m.pendingTextureLoads === 0);
}, { timeout : 10000 }).then(function() {
- var finishedColor = verifyRender(m);
- expect(finishedColor).not.toEqual(loadedColor);
+ expect(scene).notToRender(loadedColor);
primitives.remove(m);
});
});
@@ -1588,10 +1608,17 @@ defineSuite([
it('Loads with incrementallyLoadTextures set to false', function() {
return loadModelJson(texturedBoxModel.gltf, {
- incrementallyLoadTextures : false
+ incrementallyLoadTextures : false,
+ show : true
}).then(function(m) {
// Get the rendered color of the model before textures are loaded
- var loadedColor = verifyRender(m);
+ var loadedColor;
+
+ m.zoomTo();
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ loadedColor = rgba;
+ });
pollToPromise(function() {
// Render scene to progressively load textures (they should already be loaded)
@@ -1599,8 +1626,7 @@ defineSuite([
// Textures have finished loading
return !defined(m._loadResources);
}, { timeout : 10000 }).then(function() {
- var finishedColor = verifyRender(m);
- expect(finishedColor).toEqual(loadedColor);
+ expect(scene).toRender(loadedColor);
primitives.remove(m);
});
});
@@ -1638,10 +1664,10 @@ defineSuite([
return loadModel(boxNoLightUrl).then(function(m) {
// Verify that we render a black model because lighting is completely off
expect(m.ready).toBe(true);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
m.show = true;
m.zoomTo();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
m.show = false;
primitives.remove(m);
@@ -1731,8 +1757,13 @@ defineSuite([
var rotateZ = Matrix3.fromRotationZ(CesiumMath.toRadians(90.0));
// Each side of the cube should be a different color
- var oldPixelColor = scene.renderForSpecs();
- expect(oldPixelColor).not.toEqual([0, 0, 0, 255]);
+ var oldPixelColor;
+
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ oldPixelColor = rgba;
+ });
+
for(var i = 0; i < 6; i++) {
var rotate = rotateZ;
if (i % 3 === 0) {
@@ -1743,17 +1774,19 @@ defineSuite([
}
Matrix4.multiplyByMatrix3(m.modelMatrix, rotate, m.modelMatrix);
- var pixelColor = scene.renderForSpecs();
- expect(pixelColor).not.toEqual([0, 0, 0, 255]);
- expect(pixelColor).not.toEqual(oldPixelColor);
- oldPixelColor = pixelColor;
+ /* jshint loopfunc: true */
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ expect(rgba).not.toEqual(oldPixelColor);
+ oldPixelColor = rgba;
+ });
}
}
it('loads a gltf with color attributes', function() {
return loadModel(boxColorUrl).then(function(m) {
expect(m.ready).toBe(true);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
m.show = true;
m.zoomTo();
testBoxSideColors(m);
@@ -1764,7 +1797,7 @@ defineSuite([
it('loads a gltf with WEB3D_quantized_attributes COLOR', function() {
return loadModel(boxColorQuantizedUrl).then(function(m) {
expect(m.ready).toBe(true);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
m.show = true;
m.zoomTo();
testBoxSideColors(m);
@@ -1820,6 +1853,7 @@ defineSuite([
};
var options = {
+ show : true,
precreatedAttributes : precreatedAttributes,
vertexShaderLoaded : vertexShaderLoaded,
fragmentShaderLoaded : fragmentShaderLoaded,
@@ -1827,8 +1861,8 @@ defineSuite([
};
return loadModelJson(texturedBoxModel.gltf, options).then(function(model) {
- var pixelColor = verifyRender(model);
- expect(pixelColor).toEqual([255, 255, 255, 255]);
+ model.zoomTo();
+ expect(scene).toRender([255, 255, 255, 255]);
primitives.remove(model);
});
});
@@ -1857,8 +1891,10 @@ defineSuite([
return loadModelJson(texturedBoxModel.gltf, options).then(function(model) {
model.show = true;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.custom).toEqual('custom');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.custom).toEqual('custom');
+ });
+
primitives.remove(model);
});
});
@@ -1929,51 +1965,58 @@ defineSuite([
model.zoomTo();
// Model is originally red
- var sourceColor = scene.renderForSpecs();
- expect(sourceColor[0]).toBeGreaterThan(0);
- expect(sourceColor[1]).toEqual(0);
+ var sourceColor;
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(0);
+ expect(rgba[1]).toEqual(0);
+ sourceColor = rgba;
+ });
// Check MIX
model.colorBlendMode = ColorBlendMode.MIX;
model.color = Color.LIME;
model.colorBlendAmount = 0.0;
- var color = scene.renderForSpecs();
- expect(color).toEqual(sourceColor);
+ expect(scene).toRender(sourceColor);
model.colorBlendAmount = 0.5;
- color = scene.renderForSpecs();
- expect(color[0]).toBeGreaterThan(0);
- expect(color[1]).toBeGreaterThan(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(0);
+ expect(rgba[1]).toBeGreaterThan(0);
+ });
model.colorBlendAmount = 1.0;
- color = scene.renderForSpecs();
- expect(color[0]).toEqual(0);
- expect(color[1]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toEqual(0);
+ expect(rgba[1]).toEqual(255);
+ });
// Check REPLACE
model.colorBlendMode = ColorBlendMode.REPLACE;
model.colorBlendAmount = 0.5; // Should have no effect
- color = scene.renderForSpecs();
- expect(color[0]).toEqual(0);
- expect(color[1]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toEqual(0);
+ expect(rgba[1]).toEqual(255);
+ });
// Check HIGHLIGHT
model.colorBlendMode = ColorBlendMode.HIGHLIGHT;
model.color = Color.DARKGRAY;
- color = scene.renderForSpecs();
- expect(sourceColor[0]).toBeGreaterThan(0);
- expect(sourceColor[0]).toBeLessThan(255);
- expect(sourceColor[1]).toEqual(0);
- expect(sourceColor[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(0);
+ expect(rgba[0]).toBeLessThan(255);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
// Check alpha
model.colorBlendMode = ColorBlendMode.REPLACE;
model.color = Color.fromAlpha(Color.LIME, 0.5);
- color = scene.renderForSpecs();
- expect(color[0]).toEqual(0);
- expect(color[1]).toBeLessThan(255);
- expect(color[1]).toBeGreaterThan(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toEqual(0);
+ expect(rgba[1]).toBeLessThan(255);
+ expect(rgba[1]).toBeGreaterThan(0);
+ });
// No commands are issued when the alpha is 0.0
model.color = Color.fromAlpha(Color.LIME, 0.0);
diff --git a/Specs/Scene/MoonSpec.js b/Specs/Scene/MoonSpec.js
index a743dfe7ec6c..14dbc1877b38 100644
--- a/Specs/Scene/MoonSpec.js
+++ b/Specs/Scene/MoonSpec.js
@@ -57,25 +57,25 @@ defineSuite([
});
it('draws in 3D', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.moon = new Moon();
lookAtMoon(scene.camera, scene.frameState.time);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
scene.moon = scene.moon.destroy();
});
it('does not render when show is false', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.moon = new Moon();
lookAtMoon(scene.camera, scene.frameState.time);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
scene.moon.show = false;
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.moon = scene.moon.destroy();
});
diff --git a/Specs/Scene/MultifrustumSpec.js b/Specs/Scene/MultifrustumSpec.js
index dfa07c5481fc..07a6b59e196d 100644
--- a/Specs/Scene/MultifrustumSpec.js
+++ b/Specs/Scene/MultifrustumSpec.js
@@ -149,25 +149,27 @@ defineSuite([
it('renders primitive in closest frustum', function() {
createBillboards();
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
- expect(pixels[3]).toEqual(255);
-
- pixels = scene.renderForSpecs();
- expect(pixels[0]).toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
- expect(pixels[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ expect(rgba[3]).toEqual(255);
+ });
+
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ expect(rgba[3]).toEqual(255);
+ });
});
it('renders primitive in middle frustum', function() {
createBillboards();
billboard0.color = new Color(1.0, 1.0, 1.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders primitive in last frustum', function() {
@@ -176,8 +178,8 @@ defineSuite([
billboard0.color = color;
billboard1.color = color;
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
});
it('renders primitive in last frustum with debugShowFrustums', function() {
@@ -297,8 +299,8 @@ defineSuite([
var primitive = createPrimitive(false);
primitives.add(primitive);
- expect(scene.renderForSpecs()).toEqual([255, 255, 0, 255]);
- expect(scene.renderForSpecs()).toEqual([255, 255, 0, 255]);
+ expect(scene).toRender([255, 255, 0, 255]);
+ expect(scene).toRender([255, 255, 0, 255]);
});
it('renders only in the closest frustum', function() {
@@ -312,17 +314,19 @@ defineSuite([
primitive.color = new Color(1.0, 1.0, 0.0, 0.5);
primitives.add(primitive);
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
- expect(pixels[3]).toEqual(255);
-
- pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
- expect(pixels[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ expect(rgba[3]).toEqual(255);
+ });
+
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ expect(rgba[3]).toEqual(255);
+ });
});
it('render without a central body or any primitives', function() {
diff --git a/Specs/Scene/PerInstanceColorAppearanceSpec.js b/Specs/Scene/PerInstanceColorAppearanceSpec.js
index 4c87261aa69d..111a4befc939 100644
--- a/Specs/Scene/PerInstanceColorAppearanceSpec.js
+++ b/Specs/Scene/PerInstanceColorAppearanceSpec.js
@@ -71,10 +71,10 @@ defineSuite([
it('renders', function() {
primitive.appearance = new PerInstanceColorAppearance();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders flat', function() {
@@ -84,10 +84,10 @@ defineSuite([
closed : true
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Scene/PickSpec.js b/Specs/Scene/PickSpec.js
index 4f462a08243f..45b4e9fa4777 100644
--- a/Specs/Scene/PickSpec.js
+++ b/Specs/Scene/PickSpec.js
@@ -92,24 +92,21 @@ defineSuite([
}
var rectangle = createRectangle();
- var pickedObject = scene.pick(new Cartesian2(0, 0));
- expect(pickedObject.primitive).toEqual(rectangle);
+ expect(scene).toPickPrimitive(rectangle);
});
it('does not pick primitives when show is false', function() {
var rectangle = createRectangle();
rectangle.show = false;
- var pickedObject = scene.pick(new Cartesian2(0, 0));
- expect(pickedObject).not.toBeDefined();
+ expect(scene).notToPick();
});
it('does not pick primitives when alpha is zero', function() {
var rectangle = createRectangle();
rectangle.appearance.material.uniforms.color.alpha = 0.0;
- var pickedObject = scene.pick(new Cartesian2(0, 0));
- expect(pickedObject).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks the top primitive', function() {
@@ -117,8 +114,7 @@ defineSuite([
var rectangle2 = createRectangle();
rectangle2.height = 0.01;
- var pickedObject = scene.pick(new Cartesian2(0, 0));
- expect(pickedObject.primitive).toEqual(rectangle2);
+ expect(scene).toPickPrimitive(rectangle2);
});
it('does not drill pick undefined window positions', function() {
@@ -132,10 +128,11 @@ defineSuite([
var rectangle2 = createRectangle();
rectangle2.height = 0.01;
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(2);
- expect(pickedObjects[0].primitive).toEqual(rectangle2);
- expect(pickedObjects[1].primitive).toEqual(rectangle1);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(2);
+ expect(pickedObjects[0].primitive).toEqual(rectangle2);
+ expect(pickedObjects[1].primitive).toEqual(rectangle1);
+ });
});
it('does not drill pick when show is false', function() {
@@ -144,9 +141,10 @@ defineSuite([
rectangle2.height = 0.01;
rectangle2.show = false;
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(1);
- expect(pickedObjects[0].primitive).toEqual(rectangle1);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(1);
+ expect(pickedObjects[0].primitive).toEqual(rectangle1);
+ });
});
it('does not drill pick when alpha is zero', function() {
@@ -155,9 +153,10 @@ defineSuite([
rectangle2.height = 0.01;
rectangle2.appearance.material.uniforms.color.alpha = 0.0;
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(1);
- expect(pickedObjects[0].primitive).toEqual(rectangle1);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(1);
+ expect(pickedObjects[0].primitive).toEqual(rectangle1);
+ });
});
it('can drill pick batched Primitives with show attribute', function() {
@@ -204,12 +203,13 @@ defineSuite([
appearance : new EllipsoidSurfaceAppearance()
}));
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(2);
- expect(pickedObjects[0].primitive).toEqual(primitive);
- expect(pickedObjects[0].id).toEqual(3);
- expect(pickedObjects[1].primitive).toEqual(primitive);
- expect(pickedObjects[1].id).toEqual(1);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(2);
+ expect(pickedObjects[0].primitive).toEqual(primitive);
+ expect(pickedObjects[0].id).toEqual(3);
+ expect(pickedObjects[1].primitive).toEqual(primitive);
+ expect(pickedObjects[1].id).toEqual(1);
+ });
});
it('can drill pick without ID', function() {
@@ -239,9 +239,10 @@ defineSuite([
appearance : new EllipsoidSurfaceAppearance()
}));
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(1);
- expect(pickedObjects[0].primitive).toEqual(primitive);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(1);
+ expect(pickedObjects[0].primitive).toEqual(primitive);
+ });
});
it('can drill pick batched Primitives without show attribute', function() {
@@ -279,10 +280,11 @@ defineSuite([
appearance : new EllipsoidSurfaceAppearance()
}));
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
- expect(pickedObjects.length).toEqual(1);
- expect(pickedObjects[0].primitive).toEqual(primitive);
- expect(pickedObjects[0].id).toEqual(3);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(1);
+ expect(pickedObjects[0].primitive).toEqual(primitive);
+ expect(pickedObjects[0].id).toEqual(3);
+ });
});
it('stops drill picking when the limit is reached.', function() {
@@ -293,11 +295,12 @@ defineSuite([
rectangle3.height = 0.02;
rectangle4.height = 0.03;
- var pickedObjects = scene.drillPick(new Cartesian2(0, 0), 3);
- expect(pickedObjects.length).toEqual(3);
- expect(pickedObjects[0].primitive).toEqual(rectangle4);
- expect(pickedObjects[1].primitive).toEqual(rectangle3);
- expect(pickedObjects[2].primitive).toEqual(rectangle2);
+ expect(scene).toDrillPickAndCall(function(pickedObjects) {
+ expect(pickedObjects.length).toEqual(3);
+ expect(pickedObjects[0].primitive).toEqual(rectangle4);
+ expect(pickedObjects[1].primitive).toEqual(rectangle3);
+ expect(pickedObjects[2].primitive).toEqual(rectangle2);
+ });
});
it('picks in 2D', function() {
@@ -305,9 +308,7 @@ defineSuite([
camera.setView({ destination : primitiveRectangle });
var rectangle = createRectangle();
scene.initializeFrame();
- var pickedObject = scene.pick(new Cartesian2(0, 0));
- expect(pickedObject).toBeDefined();
- expect(pickedObject.primitive).toEqual(rectangle);
+ expect(scene).toPickPrimitive(rectangle);
scene.morphTo3D(0.0);
});
@@ -316,9 +317,7 @@ defineSuite([
camera.setView({ destination : primitiveRectangle });
var rectangle = createRectangle();
scene.initializeFrame();
- var pickedObject = scene.pick(new Cartesian2(0.0, 0.0));
- expect(pickedObject).toBeDefined();
- expect(pickedObject.primitive).toEqual(rectangle);
+ expect(scene).toPickPrimitive(rectangle);
scene.morphTo3D(0.0);
});
}, 'WebGL');
diff --git a/Specs/Scene/PointAppearanceSpec.js b/Specs/Scene/PointAppearanceSpec.js
index e89983aaf320..0563a14aa576 100644
--- a/Specs/Scene/PointAppearanceSpec.js
+++ b/Specs/Scene/PointAppearanceSpec.js
@@ -78,9 +78,9 @@ defineSuite([
it('renders', function() {
primitive.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
primitive.show = true;
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
primitive.show = false;
});
@@ -89,16 +89,17 @@ defineSuite([
primitive.appearance.uniforms.highlightColor.alpha = 0.5;
primitive.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
primitive.show = true;
- var pixelColor = scene.renderForSpecs();
- expect(pixelColor[0]).toBeGreaterThan(0);
- expect(pixelColor[0]).toBeLessThan(255);
- expect(pixelColor[1]).toBeGreaterThan(0);
- expect(pixelColor[1]).toBeLessThan(255);
- expect(pixelColor[2]).toEqual(0);
- expect(pixelColor[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).toBeGreaterThan(0);
+ expect(rgba[0]).toBeLessThan(255);
+ expect(rgba[1]).toBeGreaterThan(0);
+ expect(rgba[1]).toBeLessThan(255);
+ expect(rgba[2]).toEqual(0);
+ expect(rgba[3]).toEqual(255);
+ });
primitive.show = false;
});
@@ -128,9 +129,9 @@ defineSuite([
scene.primitives.add(primitive);
primitive.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
primitive.show = true;
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
scene.primitives.remove(primitive);
});
diff --git a/Specs/Scene/PointPrimitiveCollectionSpec.js b/Specs/Scene/PointPrimitiveCollectionSpec.js
index 978a1ced9842..3f00c48dddfc 100644
--- a/Specs/Scene/PointPrimitiveCollectionSpec.js
+++ b/Specs/Scene/PointPrimitiveCollectionSpec.js
@@ -79,7 +79,7 @@ defineSuite([
it('can add and remove before first render.', function() {
var p = pointPrimitives.add();
pointPrimitives.remove(p);
- expect(scene.renderForSpecs()).toBeDefined();
+ scene.renderForSpecs();
});
it('explicitly constructs a pointPrimitive', function() {
@@ -205,10 +205,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders pointPrimitive with translucencyByDistance', function() {
@@ -219,10 +219,10 @@ defineSuite([
});
camera.position = new Cartesian3(2.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(4.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('throws scaleByDistance with nearDistance === farDistance', function() {
@@ -283,13 +283,13 @@ defineSuite([
});
camera.position = new Cartesian3(200.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
camera.position = new Cartesian3(50.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
camera.position = new Cartesian3(5.0, 0.0, 0.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('throws new pointPrimitive with invalid distanceDisplayCondition (near >= far)', function() {
@@ -440,7 +440,7 @@ defineSuite([
});
it('does not render when constructed', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('modifies and removes a pointPrimitive, then renders', function() {
@@ -453,11 +453,11 @@ defineSuite([
color : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
p1.pixelSize = 2.0;
pointPrimitives.remove(p1);
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders a green pointPrimitive', function() {
@@ -466,7 +466,7 @@ defineSuite([
color : Color.LIME
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('adds and renders a pointPrimitive', function() {
@@ -475,14 +475,14 @@ defineSuite([
color : Color.LIME
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
pointPrimitives.add({
position : new Cartesian3(1.0, 0.0, 0.0), // Closer to camera
color : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('removes and renders a pointPrimitive', function() {
@@ -495,10 +495,10 @@ defineSuite([
color : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
pointPrimitives.remove(bluePointPrimitive);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('removes all pointPrimitives and renders', function() {
@@ -507,10 +507,10 @@ defineSuite([
color : Color.LIME
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
pointPrimitives.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('removes all pointPrimitives, adds a pointPrimitive, and renders', function() {
@@ -519,7 +519,7 @@ defineSuite([
color : Color.LIME
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
pointPrimitives.removeAll();
pointPrimitives.add({
@@ -527,7 +527,7 @@ defineSuite([
color : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using pointPrimitive show property', function() {
@@ -541,12 +541,12 @@ defineSuite([
color : Color.BLUE
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
greenPointPrimitive.show = false;
bluePointPrimitive.show = true;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('renders using pointPrimitive position property', function() {
@@ -555,13 +555,13 @@ defineSuite([
color : Color.LIME
});
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
p.position = new Cartesian3(20.0, 0.0, 0.0); // Behind camera
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
p.position = new Cartesian3(1.0, 0.0, 0.0); // Back in front of camera
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders using pointPrimitive color property', function() {
@@ -570,14 +570,14 @@ defineSuite([
color : Color.WHITE
});
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
p.color = new Color(1.0, 0.0, 1.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([255, 0, 255, 255]);
+ expect(scene).toRender([255, 0, 255, 255]);
// Update a second time since it goes through a different vertex array update path
p.color = new Color(0.0, 1.0, 0.0, 1.0);
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
});
it('renders bounding volume with debugShowBoundingVolume', function() {
@@ -588,7 +588,7 @@ defineSuite([
});
pointPrimitives.debugShowBoundingVolume = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('updates 10% of pointPrimitives', function() {
@@ -601,17 +601,17 @@ defineSuite([
}
// First render - default pointPrimitive color is white.
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
pointPrimitives.get(3).color = new Color(0.0, 1.0, 0.0, 1.0);
// Second render - pointPrimitive is green
- expect(scene.renderForSpecs()).toEqual([0, 255, 0, 255]);
+ expect(scene).toRender([0, 255, 0, 255]);
pointPrimitives.get(3).color = new Color(1.0, 0.0, 0.0, 1.0);
// Third render - update goes through a different vertex array update path
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
});
it('renders more than 64K pointPrimitives', function() {
@@ -627,7 +627,7 @@ defineSuite([
color : Color.WHITE
});
- expect(scene.renderForSpecs()).toEqual([255, 255, 255, 255]);
+ expect(scene).toRender([255, 255, 255, 255]);
});
it('is picked', function() {
@@ -637,9 +637,10 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(p);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id');
+ });
});
it('can change pick id', function() {
@@ -649,15 +650,17 @@ defineSuite([
id : 'id'
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(p);
- expect(pick.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id');
+ });
p.id = 'id2';
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(p);
- expect(pick.id).toEqual('id2');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id2');
+ });
});
it('is not picked', function() {
@@ -667,8 +670,7 @@ defineSuite([
color : Color.WHITE
});
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a pointPrimitive using scaleByDistance', function() {
@@ -680,15 +682,13 @@ defineSuite([
var scaleByDistance = new NearFarScalar(1.0, 4.0, 3.0e9, 2.0);
p.scaleByDistance = scaleByDistance;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(p);
+ expect(scene).toPickPrimitive(p);
scaleByDistance.nearValue = 0.0;
scaleByDistance.farValue = 0.0;
p.scaleByDistance = scaleByDistance;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks a pointPrimitive using translucencyByDistance', function() {
@@ -700,15 +700,13 @@ defineSuite([
var translucency = new NearFarScalar(1.0, 0.9, 3.0e9, 0.8);
p.translucencyByDistance = translucency;
- var pick = scene.pick(new Cartesian2(0, 0));
- expect(pick.primitive).toEqual(p);
+ expect(scene).toPickPrimitive(p);
translucency.nearValue = 0.0;
translucency.farValue = 0.0;
p.translucencyByDistance = translucency;
- pick = scene.pick(new Cartesian2(0, 0));
- expect(pick).not.toBeDefined();
+ expect(scene).notToPick();
});
it('computes screen space position', function() {
diff --git a/Specs/Scene/PolylineCollectionSpec.js b/Specs/Scene/PolylineCollectionSpec.js
index 04464b91230c..3988ef54366c 100644
--- a/Specs/Scene/PolylineCollectionSpec.js
+++ b/Specs/Scene/PolylineCollectionSpec.js
@@ -351,10 +351,10 @@ defineSuite([
});
it('does not render when constructed', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders polylines. one polyline with no positions', function() {
@@ -380,10 +380,10 @@ defineSuite([
positions: positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not crash if polyline has one position', function() {
@@ -395,10 +395,10 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders polylines with duplicate positions at construction', function() {
@@ -411,10 +411,10 @@ defineSuite([
]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders polylines with duplicate positions after setting positions', function() {
@@ -426,10 +426,10 @@ defineSuite([
new Cartesian3(0.0, 2000000.0, 0.0)
];
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('A polyline that used to cross the IDL but now does not, triggers vertex creation (This code used to crash)', function() {
@@ -497,10 +497,10 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('creates two vertex arrays and renders', function() {
@@ -521,19 +521,19 @@ defineSuite([
var p1 = polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p1.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
@@ -565,10 +565,10 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders a polyline with no positions', function() {
@@ -589,20 +589,20 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.add({
positions : []
});
scene.primitives.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders an updated polyline with no positions using set positions', function() {
@@ -623,24 +623,24 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var p2 = polylines.add({
positions : []
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
//recreates vertex array because buffer usage changed
p2.positions = [];
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
//should call PolylineCollection.writePositionsUpdate
p2.positions = [];
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders an updated polyline with no positions using show', function() {
@@ -661,23 +661,23 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var p2 = polylines.add({
positions : []
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
//recreates vertex array because buffer usage changed
p2.show = false;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
//should call PolylineCollection.writeMiscUpdate
p2.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders an updated polyline with no positions using material', function() {
@@ -698,21 +698,21 @@ defineSuite([
polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var p2 = polylines.add({
positions : []
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
//recreates vertex array because buffer usage changed
p2.material = Material.fromType(Material.PolylineOutlineType);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('changes buffer usage after 100 iterations of not changing', function() {
@@ -733,17 +733,17 @@ defineSuite([
var p = polylines.add({
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
// changes buffer usage, recreates vertex arrays
p.positions = positions;
for(var j = 0; j < 101; ++j){
scene.render();
}
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
@@ -777,10 +777,10 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders bounding volume with debugShowBoundingVolume', function() {
@@ -801,10 +801,10 @@ defineSuite([
});
var bounds = BoundingSphere.fromPoints(p.positions);
scene.camera.viewBoundingSphere(bounds);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render', function() {
@@ -820,13 +820,13 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('modifies and removes a polyline, then renders', function() {
@@ -842,14 +842,14 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.remove(p);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders a green polyline', function() {
@@ -865,10 +865,10 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('adds and renders a polyline', function() {
@@ -884,10 +884,10 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.add({
positions : [{
@@ -901,7 +901,7 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('removes and renders a polyline', function() {
@@ -928,14 +928,14 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.remove(bluePolyline);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('removes all polylines and renders', function() {
@@ -951,14 +951,14 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('removes all polylines, adds a polyline, and renders', function() {
@@ -974,14 +974,14 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
polylines.removeAll();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
polylines.add({
positions : [{
@@ -995,7 +995,7 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders using polyline positions property', function() {
@@ -1011,10 +1011,10 @@ defineSuite([
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p.positions = [{
x : 0.0,
@@ -1025,7 +1025,7 @@ defineSuite([
y : 1000000.0,
z : -2000000.0
}]; // Behind viewer
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
p.positions = [{
x : 0.0,
@@ -1036,7 +1036,7 @@ defineSuite([
y : 1000000.0,
z : 0.0
}]; // Back in front of viewer
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders and updates one polyline from many polylines using show property', function() {
@@ -1077,16 +1077,16 @@ defineSuite([
width : 2
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
p.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders using polyline show property', function() {
@@ -1103,16 +1103,16 @@ defineSuite([
show:true
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
p.show = true;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders four polylines with different widths', function() {
@@ -1152,10 +1152,10 @@ defineSuite([
}],
width : 7
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders three polylines with different widths and updates one', function() {
@@ -1191,16 +1191,16 @@ defineSuite([
}],
width : 7
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p2.material = Material.fromType(Material.PolylineOutlineType);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p2.material = Material.fromType(Material.ColorType);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('does not render with width 0.0', function() {
@@ -1217,13 +1217,13 @@ defineSuite([
width : 7
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
line.width = 0.0;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders with a distance display condition', function() {
@@ -1252,13 +1252,13 @@ defineSuite([
var radius = boundingSphere.radius;
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + near - 10.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + near + 1.0));
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + far + 10.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('changes polyline position size recreates vertex arrays', function() {
@@ -1278,13 +1278,13 @@ defineSuite([
positions : positions
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p.positions = positions;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
positions.push({
x : 0.0,
@@ -1293,7 +1293,7 @@ defineSuite([
});
p.positions = positions;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('changes polyline width property', function() {
@@ -1319,19 +1319,19 @@ defineSuite([
z : 0.0
}]
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(polylines);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p1.width = 2;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p2.width = 2;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
p1.width = 1;
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
@@ -1350,9 +1350,10 @@ defineSuite([
});
scene.primitives.add(polylines);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p);
- expect(pickedObject.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id');
+ });
});
it('can change pick id', function() {
@@ -1370,15 +1371,17 @@ defineSuite([
});
scene.primitives.add(polylines);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p);
- expect(pickedObject.id).toEqual('id');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id');
+ });
p.id = 'id2';
- pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p);
- expect(pickedObject.id).toEqual('id2');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(p);
+ expect(result.id).toEqual('id2');
+ });
});
it('is not picked (show === false)', function() {
@@ -1396,7 +1399,7 @@ defineSuite([
});
scene.primitives.add(polylines);
- expect(scene.pickForSpecs()).toBeUndefined();
+ expect(scene).notToPick();
});
it('is not picked (alpha === 0.0)', function() {
@@ -1414,7 +1417,7 @@ defineSuite([
p.material.uniforms.color.alpha = 0.0;
scene.primitives.add(polylines);
- expect(scene.pickForSpecs()).toBeUndefined();
+ expect(scene).notToPick();
});
it('does not equal undefined', function() {
diff --git a/Specs/Scene/PolylineColorAppearanceSpec.js b/Specs/Scene/PolylineColorAppearanceSpec.js
index 919be827a048..39df4113e094 100644
--- a/Specs/Scene/PolylineColorAppearanceSpec.js
+++ b/Specs/Scene/PolylineColorAppearanceSpec.js
@@ -72,10 +72,10 @@ defineSuite([
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Scene/PolylineMaterialAppearanceSpec.js b/Specs/Scene/PolylineMaterialAppearanceSpec.js
index 5e48a035adab..ef239101a8c8 100644
--- a/Specs/Scene/PolylineMaterialAppearanceSpec.js
+++ b/Specs/Scene/PolylineMaterialAppearanceSpec.js
@@ -69,10 +69,10 @@ defineSuite([
asynchronous : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
}, 'WebGL');
diff --git a/Specs/Scene/PrimitiveCollectionSpec.js b/Specs/Scene/PrimitiveCollectionSpec.js
index d1495de85684..e82772cc6d2b 100644
--- a/Specs/Scene/PrimitiveCollectionSpec.js
+++ b/Specs/Scene/PrimitiveCollectionSpec.js
@@ -90,14 +90,14 @@ defineSuite([
scene.primitives.removeAll();
scene.camera.setView({ destination : rectangle });
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitives);
if (defined(color)) {
- expect(scene.renderForSpecs()).toEqual(color);
+ expect(scene).toRender(color);
} else {
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
}
}
@@ -293,8 +293,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(l);
+ expect(scene).toPickPrimitive(l);
});
it('does not pick', function() {
@@ -305,8 +304,7 @@ defineSuite([
verifyPrimitivesRender(primitives, [0, 0, 0, 255]);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject).not.toBeDefined();
+ expect(scene).notToPick();
});
it('picks child composites', function() {
@@ -319,8 +317,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(l);
+ expect(scene).toPickPrimitive(l);
});
it('picks a primitive added with render order (0)', function() {
@@ -332,8 +329,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p1);
+ expect(scene).toPickPrimitive(p1);
});
it('picks a primitive added with render order (1)', function() {
@@ -345,8 +341,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p0);
+ expect(scene).toPickPrimitive(p0);
});
it('picks a primitive added with raise (0)', function() {
@@ -359,8 +354,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p1);
+ expect(scene).toPickPrimitive(p1);
});
it('picks a primitive added with raise (1)', function() {
@@ -373,8 +367,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p0);
+ expect(scene).toPickPrimitive(p0);
});
it('picks a primitive added with raiseToTop (0)', function() {
@@ -387,8 +380,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p1);
+ expect(scene).toPickPrimitive(p1);
});
it('picks a primitive added with raiseToTop (1)', function() {
@@ -401,8 +393,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p0);
+ expect(scene).toPickPrimitive(p0);
});
it('picks a primitive added with lower (0)', function() {
@@ -415,8 +406,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p0);
+ expect(scene).toPickPrimitive(p0);
});
it('picks a primitive added with lower (1)', function() {
@@ -429,8 +419,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p1);
+ expect(scene).toPickPrimitive(p1);
});
it('picks a primitive added with lowerToBottom (0)', function() {
@@ -443,8 +432,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p0);
+ expect(scene).toPickPrimitive(p0);
});
it('picks a primitive added with lowerToBottom (1)', function() {
@@ -457,8 +445,7 @@ defineSuite([
verifyPrimitivesRender(primitives);
- var pickedObject = scene.pickForSpecs();
- expect(pickedObject.primitive).toEqual(p1);
+ expect(scene).toPickPrimitive(p1);
});
it('is not destroyed when first constructed', function() {
diff --git a/Specs/Scene/PrimitiveCullingSpec.js b/Specs/Scene/PrimitiveCullingSpec.js
index 0adeeeaf5b9c..f54234048764 100644
--- a/Specs/Scene/PrimitiveCullingSpec.js
+++ b/Specs/Scene/PrimitiveCullingSpec.js
@@ -71,15 +71,15 @@ defineSuite([
destination : rectangle
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
if (scene.mode !== SceneMode.SCENE2D) {
// move the camera through the rectangle so that is behind the view frustum
scene.camera.moveForward(100000000.0);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
}
}
@@ -104,15 +104,15 @@ defineSuite([
destination : rectangle
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
// create the globe; it should occlude the primitive
scene.globe = new Globe();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.globe = undefined;
}
diff --git a/Specs/Scene/PrimitiveSpec.js b/Specs/Scene/PrimitiveSpec.js
index 01d76d630de6..fb3e7a0033b8 100644
--- a/Specs/Scene/PrimitiveSpec.js
+++ b/Specs/Scene/PrimitiveSpec.js
@@ -28,6 +28,8 @@ defineSuite([
'Scene/PerInstanceColorAppearance',
'Scene/SceneMode',
'Specs/BadGeometry',
+ 'Specs/createContext',
+ 'Specs/createFrameState',
'Specs/createScene',
'Specs/pollToPromise'
], function(
@@ -59,6 +61,8 @@ defineSuite([
PerInstanceColorAppearance,
SceneMode,
BadGeometry,
+ createContext,
+ createFrameState,
createScene,
pollToPromise) {
'use strict';
@@ -66,6 +70,9 @@ defineSuite([
var scene;
var context;
+ var frameStateContext;
+ var frameState;
+
var ellipsoid;
var rectangle1;
@@ -81,10 +88,13 @@ defineSuite([
scene.primitives.destroyPrimitives = false;
context = scene.context;
ellipsoid = Ellipsoid.WGS84;
+
+ frameStateContext = createContext();
});
afterAll(function() {
scene.destroyForSpecs();
+ frameStateContext.destroyForSpecs();
});
beforeEach(function() {
@@ -92,6 +102,9 @@ defineSuite([
scene.frameState.passes.render = true;
scene.frameState.passes.pick = false;
+ // Mock frameState, separate from scene.frameState, used for test that call primitive.update directly
+ frameState = createFrameState(frameStateContext);
+
rectangle1 = Rectangle.fromDegrees(-80.0, 20.0, -70.0, 30.0);
rectangle2 = Rectangle.fromDegrees(70.0, 20.0, 80.0, 30.0);
@@ -232,7 +245,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.commandList.length = 0;
primitive.update(frameState);
expect(frameState.commandList.length).toEqual(0);
@@ -245,7 +257,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
primitive.update(frameState);
expect(frameState.commandList.length).toBeGreaterThan(0);
@@ -262,7 +273,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.passes.render = false;
frameState.passes.pick = false;
@@ -277,7 +287,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.mode = SceneMode.SCENE2D;
frameState.scene3DOnly = true;
@@ -292,7 +301,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.mode = SceneMode.COLUMBUS_VIEW;
frameState.scene3DOnly = true;
@@ -334,10 +342,10 @@ defineSuite([
if (defined(rectangle)){
scene.camera.setView({ destination : rectangle });
}
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(primitive);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
}
it('renders in Columbus view when scene3DOnly is false', function() {
@@ -455,7 +463,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
primitive.update(frameState);
var commands = frameState.commandList;
expect(commands.length).toEqual(1);
@@ -481,7 +488,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.scene3DOnly = true;
var commands = frameState.commandList;
@@ -531,7 +537,6 @@ defineSuite([
var expectedModelMatrix = Matrix4.multiplyTransformation(primitiveModelMatrix, instanceModelMatrix, new Matrix4());
- var frameState = scene.frameState;
frameState.scene3DOnly = true;
var commands = frameState.commandList;
@@ -548,7 +553,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.mode = SceneMode.COLUMBUS_VIEW;
frameState.scene3DOnly = false;
@@ -574,7 +578,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
frameState.mode = SceneMode.SCENE2D;
frameState.scene3DOnly = false;
@@ -602,11 +605,12 @@ defineSuite([
scene.primitives.add(primitive);
scene.camera.setView({ destination : rectangle1 });
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[2]).toBeGreaterThanOrEqualTo(0);
- expect(pixels[3]).toEqual(255);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[2]).toBeGreaterThanOrEqualTo(0);
+ expect(rgba[3]).toEqual(255);
+ });
});
it('transforms to world coordinates', function() {
@@ -671,16 +675,20 @@ defineSuite([
scene.camera.setView({ destination : rectangle1 });
scene.primitives.add(primitive);
- var pixels = scene.renderForSpecs();
- expect(pixels).not.toEqual([0, 0, 0, 255]);
+ var pixels;
+ expect(scene).toRenderAndCall(function(rgba) {
+ pixels = rgba;
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ });
var attributes = primitive.getGeometryInstanceAttributes('rectangle1');
expect(attributes.color).toBeDefined();
attributes.color = [255, 255, 255, 255];
- var newPixels = scene.renderForSpecs();
- expect(newPixels).not.toEqual([0, 0, 0, 255]);
- expect(newPixels).not.toEqual(pixels);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ expect(rgba).not.toEqual(pixels);
+ });
});
it('modify show instance attribute', function() {
@@ -692,15 +700,13 @@ defineSuite([
scene.primitives.add(primitive);
scene.camera.setView({ destination : rectangle1 });
- var pixels = scene.renderForSpecs();
- expect(pixels).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
var attributes = primitive.getGeometryInstanceAttributes('rectangle1');
expect(attributes.show).toBeDefined();
attributes.show = [0];
- var newPixels = scene.renderForSpecs();
- expect(newPixels).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('get bounding sphere from per instance attribute', function() {
@@ -750,13 +756,13 @@ defineSuite([
var radius = boundingSphere.radius;
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + near + 1.0));
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, -CesiumMath.PI_OVER_TWO, radius + far + 1.0));
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('primitive with display condition properly transforms boundingSphere', function() {
@@ -851,15 +857,17 @@ defineSuite([
verifyPrimitiveRender(primitive, rectangle1);
- var pickObject = scene.pickForSpecs();
- expect(pickObject.primitive).toEqual(primitive);
- expect(pickObject.id).toEqual('rectangle1');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(primitive);
+ expect(result.id).toEqual('rectangle1');
+ });
verifyPrimitiveRender(primitive, rectangle2);
- pickObject = scene.pickForSpecs();
- expect(pickObject.primitive).toEqual(primitive);
- expect(pickObject.id).toEqual('rectangle2');
+ expect(scene).toPickAndCall(function(result) {
+ expect(result.primitive).toEqual(primitive);
+ expect(result.id).toEqual('rectangle2');
+ });
});
it('does not pick when allowPicking is false', function() {
@@ -872,8 +880,7 @@ defineSuite([
verifyPrimitiveRender(primitive, rectangle1);
- var pickObject = scene.pickForSpecs();
- expect(pickObject).not.toBeDefined();
+ expect(scene).notToPick();
});
it('does not cull when cull is false', function() {
@@ -884,7 +891,6 @@ defineSuite([
cull : false
});
- var frameState = scene.frameState;
frameState.commandList.length = 0;
primitive.update(frameState);
expect(frameState.commandList[0].cull).toEqual(false);
@@ -922,8 +928,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
-
expect(function() {
primitive.update(frameState);
}).toThrowDeveloperError();
@@ -955,9 +959,10 @@ defineSuite([
fail('should not be called');
}).otherwise(function(e) {
expect(e).toBe(primitive._error);
+ // Use toThrow since the error is thrown by RequireJS for the web worker import script
expect(function() {
scene.render();
- }).toThrowRuntimeError();
+ }).toThrow();
});
});
});
@@ -1044,8 +1049,6 @@ defineSuite([
})
});
- var frameState = scene.frameState;
-
return pollToPromise(function() {
primitive.update(frameState);
if (frameState.afterRender.length > 0) {
@@ -1060,6 +1063,10 @@ defineSuite([
});
it('shader validation', function() {
+ if (!!window.webglStub) {
+ return;
+ }
+
primitive = new Primitive({
geometryInstances : [rectangleInstance1, rectangleInstance2],
appearance : new MaterialAppearance({
@@ -1069,8 +1076,6 @@ defineSuite([
compressVertices : false
});
- var frameState = scene.frameState;
-
expect(function() {
primitive.update(frameState);
}).toThrowDeveloperError();
@@ -1083,7 +1088,6 @@ defineSuite([
asynchronous : false
});
- var frameState = scene.frameState;
primitive.update(frameState);
var attributes = primitive.getGeometryInstanceAttributes('rectangle1');
@@ -1100,7 +1104,6 @@ defineSuite([
allowPicking : false
});
- var frameState = scene.frameState;
frameState.afterRender.length = 0;
scene.primitives.add(primitive);
@@ -1174,7 +1177,6 @@ defineSuite([
});
var frameState = scene.frameState;
-
return pollToPromise(function() {
primitive.update(frameState);
if (frameState.afterRender.length > 0) {
@@ -1192,7 +1194,6 @@ defineSuite([
appearance : new PerInstanceColorAppearance()
});
- var frameState = scene.frameState;
primitive.update(frameState);
primitive.destroy();
diff --git a/Specs/Scene/SceneSpec.js b/Specs/Scene/SceneSpec.js
index e00d93cd4dd2..b0bca345b642 100644
--- a/Specs/Scene/SceneSpec.js
+++ b/Specs/Scene/SceneSpec.js
@@ -165,10 +165,10 @@ defineSuite([
});
it('draws background color', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.backgroundColor = Color.BLUE;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('calls afterRender functions', function() {
@@ -239,7 +239,9 @@ defineSuite([
scene.primitives.add(new CommandMockPrimitive(c));
scene.depthTestAgainstTerrain = true;
- expect(scene.renderForSpecs()[0]).not.toEqual(0); // Red bounding sphere
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0); // Red bounding sphere
+ });
});
it('debugShowCommands tints commands', function() {
@@ -288,10 +290,11 @@ defineSuite([
rectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 1.0);
scene.primitives.add(rectanglePrimitive);
+ expect(scene).toRender([255, 0, 0, 255]);
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
scene.debugShowGlobeDepth = true;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
+
scene.debugShowGlobeDepth = false;
});
@@ -309,18 +312,18 @@ defineSuite([
primitives.add(rectanglePrimitive2);
scene.camera.setView({ destination : rectangle });
-
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
primitives.raiseToTop(rectanglePrimitive1);
-
- pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).not.toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).not.toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
});
it('opaque/translucent render order (2)', function() {
@@ -337,18 +340,18 @@ defineSuite([
primitives.add(rectanglePrimitive2);
scene.camera.setView({ destination : rectangle });
-
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
primitives.raiseToTop(rectanglePrimitive1);
-
- pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
});
it('renders fast path with no translucent primitives', function() {
@@ -361,11 +364,11 @@ defineSuite([
primitives.add(rectanglePrimitive);
scene.camera.setView({ destination : rectangle });
-
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
});
it('renders with OIT and without FXAA', function() {
@@ -378,13 +381,12 @@ defineSuite([
primitives.add(rectanglePrimitive);
scene.camera.setView({ destination : rectangle });
-
scene.fxaa = false;
-
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
});
it('renders with forced FXAA', function() {
@@ -438,15 +440,16 @@ defineSuite([
s.camera.setView({ destination : rectangle });
- var pixels = s.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(s).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
s.destroyForSpecs();
});
- it('setting a central body', function() {
+ it('setting a globe', function() {
var scene = createScene();
var ellipsoid = Ellipsoid.UNIT_SPHERE;
var globe = new Globe(ellipsoid);
@@ -470,7 +473,7 @@ defineSuite([
scene.destroyForSpecs();
});
- it('renders a central body', function() {
+ it('renders a globe', function() {
var s = createScene();
s.globe = new Globe(Ellipsoid.UNIT_SPHERE);
@@ -478,11 +481,14 @@ defineSuite([
s.camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
s.camera.direction = Cartesian3.negate(Cartesian3.normalize(s.camera.position, new Cartesian3()), new Cartesian3());
- s.renderForSpecs();
+ // To avoid Jasmine's spec has no expectations error
+ expect(true).toEqual(true);
- return pollToPromise(function() {
- render(s.frameState, s.globe);
- return !jasmine.matchersUtil.equals(s._context.readPixels(), [0, 0, 0, 0]);
+ return expect(s).toRenderAndCall(function() {
+ return pollToPromise(function() {
+ render(s.frameState, s.globe);
+ return !jasmine.matchersUtil.equals(s._context.readPixels(), [0, 0, 0, 0]);
+ });
});
});
@@ -503,10 +509,11 @@ defineSuite([
s.camera.setView({ destination : rectangle });
- var pixels = s.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(s).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
}
s.destroyForSpecs();
@@ -532,10 +539,11 @@ defineSuite([
s.camera.setView({ destination : rectangle });
- var pixels = s.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(s).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
}
s.destroyForSpecs();
});
@@ -556,10 +564,11 @@ defineSuite([
convert : false
});
- var pixels = scene.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
});
it('renders map when the camera is on the IDL in 2D', function() {
@@ -581,10 +590,11 @@ defineSuite([
convert : false
});
- var pixels = s.renderForSpecs();
- expect(pixels[0]).not.toEqual(0);
- expect(pixels[1]).toEqual(0);
- expect(pixels[2]).toEqual(0);
+ expect(s).toRenderAndCall(function(rgba) {
+ expect(rgba[0]).not.toEqual(0);
+ expect(rgba[1]).toEqual(0);
+ expect(rgba[2]).toEqual(0);
+ });
s.destroyForSpecs();
});
@@ -604,12 +614,14 @@ defineSuite([
var uniformState = scene.context.uniformState;
- scene.renderForSpecs();
- expect(uniformState.globeDepthTexture).not.toBeDefined();
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(uniformState.globeDepthTexture).not.toBeDefined();
+ });
scene.copyGlobeDepth = true;
- scene.renderForSpecs();
- expect(uniformState.globeDepthTexture).toBeDefined();
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(uniformState.globeDepthTexture).toBeDefined();
+ });
}
scene.destroyForSpecs();
@@ -623,24 +635,24 @@ defineSuite([
var rectangle = Rectangle.fromDegrees(-100.0, 30.0, -90.0, 40.0);
scene.camera.setView({ destination : rectangle });
- scene.renderForSpecs();
-
var canvas = scene.canvas;
var windowPosition = new Cartesian2(canvas.clientWidth / 2, canvas.clientHeight / 2);
- var position = scene.pickPosition(windowPosition);
- expect(position).not.toBeDefined();
+ expect(scene).toRenderAndCall(function() {
+ var position = scene.pickPosition(windowPosition);
+ expect(position).not.toBeDefined();
- var rectanglePrimitive = createRectangle(rectangle);
- rectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 1.0);
+ var rectanglePrimitive = createRectangle(rectangle);
+ rectanglePrimitive.appearance.material.uniforms.color = new Color(1.0, 0.0, 0.0, 1.0);
- var primitives = scene.primitives;
- primitives.add(rectanglePrimitive);
-
- scene.renderForSpecs();
+ var primitives = scene.primitives;
+ primitives.add(rectanglePrimitive);
+ });
- position = scene.pickPosition(windowPosition);
- expect(position).toBeDefined();
+ expect(scene).toRenderAndCall(function() {
+ var position = scene.pickPosition(windowPosition);
+ expect(position).toBeDefined();
+ });
});
it('pickPosition returns undefined when useDepthPicking is false', function() {
@@ -663,18 +675,16 @@ defineSuite([
primitives.add(rectanglePrimitive);
scene.useDepthPicking = false;
-
- scene.renderForSpecs();
-
- var position = scene.pickPosition(windowPosition);
- expect(position).not.toBeDefined();
+ expect(scene).toRenderAndCall(function() {
+ var position = scene.pickPosition(windowPosition);
+ expect(position).not.toBeDefined();
+ });
scene.useDepthPicking = true;
-
- scene.renderForSpecs();
-
- position = scene.pickPosition(windowPosition);
- expect(position).toBeDefined();
+ expect(scene).toRenderAndCall(function() {
+ var position = scene.pickPosition(windowPosition);
+ expect(position).toBeDefined();
+ });
});
it('pickPosition throws without windowPosition', function() {
diff --git a/Specs/Scene/ScreenSpaceCameraControllerSpec.js b/Specs/Scene/ScreenSpaceCameraControllerSpec.js
index e5cca443b05d..ab6d81d87287 100644
--- a/Specs/Scene/ScreenSpaceCameraControllerSpec.js
+++ b/Specs/Scene/ScreenSpaceCameraControllerSpec.js
@@ -18,7 +18,6 @@ defineSuite([
'Scene/SceneMode',
'Specs/createCamera',
'Specs/createCanvas',
- 'Specs/destroyCanvas',
'Specs/DomEventSimulator'
], function(
ScreenSpaceCameraController,
@@ -39,7 +38,6 @@ defineSuite([
SceneMode,
createCamera,
createCanvas,
- destroyCanvas,
DomEventSimulator) {
'use strict';
@@ -83,7 +81,7 @@ defineSuite([
});
afterAll(function() {
- destroyCanvas(canvas);
+ document.body.removeChild(canvas);
});
beforeEach(function() {
diff --git a/Specs/Scene/ShadowMapSpec.js b/Specs/Scene/ShadowMapSpec.js
index e432a1c7f265..b5c2dc127bd5 100644
--- a/Specs/Scene/ShadowMapSpec.js
+++ b/Specs/Scene/ShadowMapSpec.js
@@ -351,9 +351,35 @@ defineSuite([
});
}
- function render(time) {
- scene.render(time); // Computes shadow near/far for next frame
- return scene.renderForSpecs(time);
+ function renderAndExpect(rgba, time) {
+ expect({
+ scene : scene,
+ time : time,
+ primeShadowMap : true
+ }).toRender(rgba);
+ }
+
+ function renderAndReadPixels() {
+ var color;
+
+ expect({
+ scene : scene,
+ primeShadowMap : true
+ }).toRenderAndCall(function(rgba) {
+ color = rgba;
+ });
+
+ return color;
+ }
+
+ function renderAndCall(expectationCallback, time) {
+ expect({
+ scene : scene,
+ time : time,
+ primeShadowMap : true
+ }).toRenderAndCall(function(rgba) {
+ expectationCallback(rgba);
+ });
}
function verifyShadows(caster, receiver) {
@@ -362,30 +388,36 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(unshadowedColor).not.toEqual(backgroundColor);
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ var shadowedColor;
+ renderAndCall(function(rgba) {
+ shadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
// Turn shadow casting off/on
caster.shadows = ShadowMode.DISABLED;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
caster.shadows = ShadowMode.ENABLED;
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
// Turn shadow receiving off/on
receiver.shadows = ShadowMode.DISABLED;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
receiver.shadows = ShadowMode.ENABLED;
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
// Move the camera away from the shadow
scene.camera.moveRight(0.5);
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
}
it('sets default shadow map properties', function() {
@@ -450,22 +482,30 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with shadows. The area should not be shadowed because the box's texture is transparent in the center.
scene.shadowMap.enabled = true;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
// Move the camera into the shadowed area
scene.camera.moveRight(0.2);
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+
+ var shadowedColor;
+ renderAndCall(function(rgba) {
+ shadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
// Move the camera away from the shadow
scene.camera.moveRight(0.3);
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
});
it('primitive casts shadows onto another primitive', function() {
@@ -537,19 +577,24 @@ defineSuite([
return loadGlobe().then(function() {
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with globe casting off
scene.shadowMap.enabled = true;
scene.globe.shadows = ShadowMode.DISABLED;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
// Render with globe casting on
scene.globe.shadows = ShadowMode.ENABLED;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
});
});
@@ -570,17 +615,18 @@ defineSuite([
});
// Render with shadows
- var shadowedColor = render();
+ var shadowedColor = renderAndReadPixels();
// Move the camera away from the shadow
scene.camera.moveLeft(0.5);
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
- expect(unshadowedColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
// Change the light direction so the unshadowed area is now shadowed
lightCamera.lookAt(center, new Cartesian3(0.1, 0.0, 1.0));
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
});
it('sun shadow map works', function() {
@@ -598,17 +644,22 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render(startTime);
- expect(unshadowedColor).not.toEqual(backgroundColor);
+
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render(startTime);
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ }, startTime);
// Change the time so that the shadows are no longer pointing straight down
- expect(render(endTime)).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor, endTime);
scene.shadowMap = undefined;
});
@@ -663,6 +714,7 @@ defineSuite([
];
for (var i = 0; i < 6; ++i) {
+ /* jshint loopfunc: true */
var box = scene.primitives.add(Model.fromGltf({
url : boxUrl,
modelMatrix : Transforms.headingPitchRollToFixedFrame(origins[i], new HeadingPitchRoll()),
@@ -674,24 +726,28 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
// Check that setting a smaller radius works
var radius = scene.shadowMap._pointLightRadius;
scene.shadowMap._pointLightRadius = 3.0;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
scene.shadowMap._pointLightRadius = radius;
// Move the camera away from the shadow
scene.camera.moveRight(0.5);
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
scene.primitives.remove(box);
}
@@ -703,11 +759,11 @@ defineSuite([
createCascadedShadowMap();
// Render with shadows
- var shadowedColor = render();
+ var shadowedColor = renderAndReadPixels();
// Change size
scene.shadowMap.size = 256;
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
// Cascaded shadows combine four maps into one texture
expect(scene.shadowMap._shadowMapTexture.width).toBe(512);
@@ -721,14 +777,15 @@ defineSuite([
createCascadedShadowMap();
// Render with shadows
- var shadowedColor = render();
+ var shadowedColor = renderAndReadPixels();
// Render cascade colors
scene.shadowMap.debugCascadeColors = true;
expect(scene.shadowMap.dirty).toBe(true);
- var debugColor = render();
- expect(debugColor).not.toEqual(backgroundColor);
- expect(debugColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
});
it('enable soft shadows', function() {
@@ -738,21 +795,22 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
+ var unshadowedColor = renderAndReadPixels();
// Render with shadows
scene.shadowMap.enabled = true;
expect(scene.shadowMap.dirty).toBe(true);
- var shadowedColor = render();
+ var shadowedColor = renderAndReadPixels();
// Render with soft shadows
scene.shadowMap.softShadows = true;
scene.shadowMap.size = 256; // Make resolution smaller to more easily verify soft edges
scene.camera.moveRight(0.25);
- var softColor = render();
- expect(softColor).not.toEqual(backgroundColor);
- expect(softColor).not.toEqual(unshadowedColor);
- expect(softColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
});
it('changes darkness', function() {
@@ -762,17 +820,18 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
+ var unshadowedColor = renderAndReadPixels();
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
+ var shadowedColor = renderAndReadPixels();
scene.shadowMap.darkness = 0.5;
- var darkColor = render();
- expect(darkColor).not.toEqual(backgroundColor);
- expect(darkColor).not.toEqual(unshadowedColor);
- expect(darkColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
});
function depthFramebufferSupported() {
@@ -795,18 +854,19 @@ defineSuite([
floor.show = true;
createCascadedShadowMap();
- render();
-
- if (scene.context.depthTexture) {
- if (depthFramebufferSupported()) {
- expect(scene.shadowMap._usesDepthTexture).toBe(true);
- expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.DEPTH_STENCIL);
- } else {
- // Depth texture extension is supported, but it fails to create create a depth-only FBO
- expect(scene.shadowMap._usesDepthTexture).toBe(false);
- expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.RGBA);
+
+ renderAndCall(function(rgba) {
+ if (scene.context.depthTexture) {
+ if (depthFramebufferSupported()) {
+ expect(scene.shadowMap._usesDepthTexture).toBe(true);
+ expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.DEPTH_STENCIL);
+ } else {
+ // Depth texture extension is supported, but it fails to create create a depth-only FBO
+ expect(scene.shadowMap._usesDepthTexture).toBe(false);
+ expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.RGBA);
+ }
}
- }
+ });
scene.shadowMap = scene.shadowMap && scene.shadowMap.destroy();
@@ -814,9 +874,11 @@ defineSuite([
var depthTexture = scene.context._depthTexture;
scene.context._depthTexture = false;
createCascadedShadowMap();
- render();
- expect(scene.shadowMap._usesDepthTexture).toBe(false);
- expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.RGBA);
+
+ renderAndCall(function(rgba) {
+ expect(scene.shadowMap._usesDepthTexture).toBe(false);
+ expect(scene.shadowMap._shadowMapTexture.pixelFormat).toEqual(PixelFormat.RGBA);
+ });
// Re-enable extension
scene.context._depthTexture = depthTexture;
@@ -827,14 +889,16 @@ defineSuite([
floor.show = true;
createCascadedShadowMap();
- render();
- expect(scene.shadowMap.outOfView).toBe(false);
+ renderAndCall(function(rgba) {
+ expect(scene.shadowMap.outOfView).toBe(false);
+ });
var center = new Cartesian3.fromRadians(longitude, latitude, 200000);
scene.camera.lookAt(center, new HeadingPitchRange(0.0, CesiumMath.toRadians(-70.0), 5.0));
- render();
- expect(scene.shadowMap.outOfView).toBe(true);
+ renderAndCall(function(rgba) {
+ expect(scene.shadowMap.outOfView).toBe(true);
+ });
});
it('does not render shadows when the light direction is below the horizon', function() {
@@ -853,13 +917,15 @@ defineSuite([
lightCamera : lightCamera
});
- render();
- expect(scene.shadowMap.outOfView).toBe(false);
+ renderAndCall(function(rgba) {
+ expect(scene.shadowMap.outOfView).toBe(false);
+ });
// Change light direction
lightCamera.lookAt(center, new Cartesian3(0.0, 0.0, -1.0));
- render();
- expect(scene.shadowMap.outOfView).toBe(true);
+ renderAndCall(function(rgba) {
+ expect(scene.shadowMap.outOfView).toBe(true);
+ });
});
it('enable debugShow for cascaded shadow map', function() {
@@ -868,12 +934,14 @@ defineSuite([
// Shadow overlay command, shadow volume outline, camera outline, four cascade outlines, four cascade planes
scene.shadowMap.debugShow = true;
scene.shadowMap.debugFreezeFrame = true;
- render();
- expect(scene.frameState.commandList.length).toBe(13);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(13);
+ });
scene.shadowMap.debugShow = false;
- render();
- expect(scene.frameState.commandList.length).toBe(0);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(0);
+ });
});
it('enable debugShow for fixed shadow map', function() {
@@ -881,12 +949,14 @@ defineSuite([
// Overlay command, shadow volume outline, shadow volume planes
scene.shadowMap.debugShow = true;
- render();
- expect(scene.frameState.commandList.length).toBe(3);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(3);
+ });
scene.shadowMap.debugShow = false;
- render();
- expect(scene.frameState.commandList.length).toBe(0);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(0);
+ });
});
it('enable debugShow for point light shadow map', function() {
@@ -894,12 +964,14 @@ defineSuite([
// Overlay command and shadow volume outline
scene.shadowMap.debugShow = true;
- render();
- expect(scene.frameState.commandList.length).toBe(2);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(2);
+ });
scene.shadowMap.debugShow = false;
- render();
- expect(scene.frameState.commandList.length).toBe(0);
+ renderAndCall(function(rgba) {
+ expect(scene.frameState.commandList.length).toBe(0);
+ });
});
it('enable fitNearFar', function() {
@@ -907,18 +979,23 @@ defineSuite([
floor.show = true;
createShadowMapForDirectionalLight();
scene.shadowMap._fitNearFar = true; // True by default
- render();
- var shadowNearFit = scene.shadowMap._sceneCamera.frustum.near;
- var shadowFarFit = scene.shadowMap._sceneCamera.frustum.far;
+
+ var shadowNearFit;
+ var shadowFarFit;
+ renderAndCall(function(rgba) {
+ shadowNearFit = scene.shadowMap._sceneCamera.frustum.near;
+ shadowFarFit = scene.shadowMap._sceneCamera.frustum.far;
+ });
scene.shadowMap._fitNearFar = false;
- render();
- var shadowNear = scene.shadowMap._sceneCamera.frustum.near;
- var shadowFar = scene.shadowMap._sceneCamera.frustum.far;
+ renderAndCall(function(rgba) {
+ var shadowNear = scene.shadowMap._sceneCamera.frustum.near;
+ var shadowFar = scene.shadowMap._sceneCamera.frustum.far;
- // When fitNearFar is true the shadowed region is smaller
- expect(shadowNear).toBeLessThan(shadowNearFit);
- expect(shadowFar).toBeGreaterThan(shadowFarFit);
+ // When fitNearFar is true the shadowed region is smaller
+ expect(shadowNear).toBeLessThan(shadowNearFit);
+ expect(shadowFar).toBeGreaterThan(shadowFarFit);
+ });
});
it('set normalOffset', function() {
@@ -938,31 +1015,34 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ unshadowedColor = rgba;
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ var shadowedColor;
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
// Set a maximum distance where the shadows start to fade out
scene.shadowMap.maximumDistance = 6.0;
- var fadedColor = render();
- expect(fadedColor).not.toEqual(backgroundColor);
- expect(fadedColor).not.toEqual(unshadowedColor);
- expect(fadedColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
// Set a maximimum distance where the shadows are not visible
scene.shadowMap.maximumDistance = 3.0;
- expect(render()).toEqual(unshadowedColor);
+ renderAndExpect(unshadowedColor);
});
it('shadows are disabled during the pick pass', function() {
- var i;
- var count;
- var drawCommand;
var spy = spyOn(Context.prototype, 'draw').and.callThrough();
boxTranslucent.show = true;
@@ -971,26 +1051,28 @@ defineSuite([
createCascadedShadowMap();
// Render normally and expect every model shader program to be shadow related.
- render();
- count = spy.calls.count();
- for (i = 0; i < count; ++i) {
- drawCommand = spy.calls.argsFor(i)[0];
- if (drawCommand.owner.primitive instanceof Model) {
- expect(drawCommand.shaderProgram._fragmentShaderText.indexOf('czm_shadow') !== -1).toBe(true);
+ renderAndCall(function(rgba) {
+ var count = spy.calls.count();
+ for (var i = 0; i < count; ++i) {
+ var drawCommand = spy.calls.argsFor(i)[0];
+ if (drawCommand.owner.primitive instanceof Model) {
+ expect(drawCommand.shaderProgram._fragmentShaderText.indexOf('czm_shadow') !== -1).toBe(true);
+ }
}
- }
+ });
// Do the pick pass and expect every model shader program to not be shadow related. This also checks
// that there are no shadow cast commands.
spy.calls.reset();
- scene.pickForSpecs();
- count = spy.calls.count();
- for (i = 0; i < count; ++i) {
- drawCommand = spy.calls.argsFor(i)[0];
- if (drawCommand.owner.primitive instanceof Model) {
- expect(drawCommand.shaderProgram._fragmentShaderText.indexOf('czm_shadow') !== -1).toBe(false);
+ expect(scene).toPickAndCall(function(result) {
+ var count = spy.calls.count();
+ for (var i = 0; i < count; ++i) {
+ var drawCommand = spy.calls.argsFor(i)[0];
+ if (drawCommand.owner.primitive instanceof Model) {
+ expect(drawCommand.shaderProgram._fragmentShaderText.indexOf('czm_shadow') !== -1).toBe(false);
+ }
}
- }
+ });
});
it('model updates derived commands when the shadow map is dirty', function() {
@@ -1002,37 +1084,45 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ var shadowedColor;
+ renderAndCall(function(rgba) {
+ shadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
// Hide floor temporarily and change the shadow map
floor.show = false;
scene.shadowMap.debugCascadeColors = true;
// Render a few frames
- render();
- render();
- render();
+ var i;
+ for (i = 0; i < 6; ++i) {
+ scene.render();
+ }
// Show the floor and render. The receive shadows shader should now be up-to-date.
floor.show = true;
- var debugShadowColor = render();
- expect(debugShadowColor).not.toEqual(backgroundColor);
- expect(debugShadowColor).not.toEqual(unshadowedColor);
- expect(debugShadowColor).not.toEqual(shadowedColor);
+ renderAndCall(function(rgba) {
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ expect(rgba).not.toEqual(shadowedColor);
+ });
// Render a few more frames
- render();
- render();
- render();
+ for (i = 0; i < 6; ++i) {
+ scene.render();
+ }
- // Expect derived commands to be update twice for both the floor and box,
+ // Expect derived commands to be updated twice for both the floor and box,
// once on the first frame and again when the shadow map is dirty
expect(spy.calls.count()).toEqual(4);
@@ -1047,14 +1137,20 @@ defineSuite([
// Render without shadows
scene.shadowMap.enabled = false;
- var unshadowedColor = render();
- expect(unshadowedColor).not.toEqual(backgroundColor);
+ var unshadowedColor;
+ renderAndCall(function(rgba) {
+ unshadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ });
// Render with shadows
scene.shadowMap.enabled = true;
- var shadowedColor = render();
- expect(shadowedColor).not.toEqual(backgroundColor);
- expect(shadowedColor).not.toEqual(unshadowedColor);
+ var shadowedColor;
+ renderAndCall(function(rgba) {
+ shadowedColor = rgba;
+ expect(rgba).not.toEqual(backgroundColor);
+ expect(rgba).not.toEqual(unshadowedColor);
+ });
scene.shadowMap._primitiveBias.polygonOffsetFactor = 1.2;
scene.shadowMap._primitiveBias.polygonOffsetFactor = 4.1;
@@ -1062,14 +1158,14 @@ defineSuite([
scene.shadowMap._primitiveBias.normalShadingSmooth = 0.4;
scene.shadowMap.debugCreateRenderStates();
scene.shadowMap.dirty = true;
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
scene.shadowMap._primitiveBias.normalOffset = false;
scene.shadowMap._primitiveBias.normalShading = false;
scene.shadowMap._primitiveBias.polygonOffset = false;
scene.shadowMap.debugCreateRenderStates();
scene.shadowMap.dirty = true;
- expect(render()).toEqual(shadowedColor);
+ renderAndExpect(shadowedColor);
});
it('destroys', function() {
diff --git a/Specs/Scene/SkyAtmosphereSpec.js b/Specs/Scene/SkyAtmosphereSpec.js
index 6e6121e261a8..874f02772b4b 100644
--- a/Specs/Scene/SkyAtmosphereSpec.js
+++ b/Specs/Scene/SkyAtmosphereSpec.js
@@ -32,7 +32,7 @@ defineSuite([
it('draws sky with camera in atmosphere', function() {
var s = new SkyAtmosphere();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
@@ -45,7 +45,7 @@ defineSuite([
it('draws sky with camera in space', function() {
var s = new SkyAtmosphere();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
@@ -59,7 +59,7 @@ defineSuite([
var s = new SkyAtmosphere();
s.setDynamicAtmosphereColor(true);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
@@ -74,7 +74,7 @@ defineSuite([
var s = new SkyAtmosphere();
s.setDynamicAtmosphereColor(false);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
@@ -101,14 +101,18 @@ defineSuite([
}
});
- var color = scene.renderForSpecs();
- expect(color).not.toEqual([0, 0, 0, 255]);
+ var color;
+ expect(scene).toRenderAndCall(function(rgba) {
+ color = rgba;
+ expect(color).not.toEqual([0, 0, 0, 255]);
+ });
// Expect color correction to change the color output.
s.hueShift = 0.5;
- var hueColor = scene.renderForSpecs();
- expect(hueColor).not.toEqual([0, 0, 0, 255]);
- expect(hueColor).not.toEqual(color);
+ expect(scene).toRenderAndCall(function(rgba) {
+ expect(rgba).not.toEqual([0, 0, 0, 255]);
+ expect(rgba).not.toEqual(color);
+ });
scene.skyAtmosphere = oldSkyAtmosphere;
});
@@ -117,7 +121,7 @@ defineSuite([
var s = new SkyAtmosphere();
s.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.render();
var command = s.update(scene.frameState);
@@ -127,7 +131,7 @@ defineSuite([
it('does not render in 2D', function() {
var s = new SkyAtmosphere();
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.mode = SceneMode.SCENE2D;
scene.render();
diff --git a/Specs/Scene/SkyBoxSpec.js b/Specs/Scene/SkyBoxSpec.js
index de55582f714f..025420e21c5d 100644
--- a/Specs/Scene/SkyBoxSpec.js
+++ b/Specs/Scene/SkyBoxSpec.js
@@ -48,10 +48,10 @@ defineSuite([
}
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.skyBox = skyBox;
- expect(scene.renderForSpecs()).toEqual([0, 0, 255, 255]);
+ expect(scene).toRender([0, 0, 255, 255]);
});
it('does not render when show is false', function() {
@@ -67,10 +67,10 @@ defineSuite([
show : false
});
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.skyBox = skyBox;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('does not render in 2D', function() {
@@ -86,10 +86,10 @@ defineSuite([
});
scene.mode = SceneMode.SCENE2D;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.skyBox = skyBox;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('does not render without a render pass', function() {
diff --git a/Specs/Scene/SunSpec.js b/Specs/Scene/SunSpec.js
index 06b2a5693047..6d8d3515a9c4 100644
--- a/Specs/Scene/SunSpec.js
+++ b/Specs/Scene/SunSpec.js
@@ -42,43 +42,43 @@ defineSuite([
}
it('draws in 3D', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.sun = new Sun();
scene.sun.glowFactor = 100;
scene.render();
viewSun(scene.camera, scene.context.uniformState);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
it('draws in Columbus view', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.mode = SceneMode.COLUMBUS_VIEW;
scene.sun = new Sun();
scene.render();
viewSun(scene.camera, scene.context.uniformState);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
it('does not render when show is false', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.sun = new Sun();
scene.render();
scene.sun.show = false;
viewSun(scene.camera, scene.context.uniformState);
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
});
it('does not render in 2D', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.mode = SceneMode.SCENE2D;
scene.sun = new Sun();
scene.render();
viewSun(scene.camera, scene.context.uniformState);
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
});
it('does not render without a render pass', function() {
@@ -100,13 +100,13 @@ defineSuite([
});
it('draws without lens flare', function() {
- expect(scene.renderForSpecs()).toEqual(backgroundColor);
+ expect(scene).toRender(backgroundColor);
scene.sun = new Sun();
scene.sun.glowFactor = 0.0;
scene.renderForSpecs();
viewSun(scene.camera, scene.context.uniformState);
- expect(scene.renderForSpecs()).not.toEqual(backgroundColor);
+ expect(scene).notToRender(backgroundColor);
});
it('isDestroyed', function() {
diff --git a/Specs/Scene/TextureAtlasSpec.js b/Specs/Scene/TextureAtlasSpec.js
index d4bff44d253d..63a52fe448da 100644
--- a/Specs/Scene/TextureAtlasSpec.js
+++ b/Specs/Scene/TextureAtlasSpec.js
@@ -74,61 +74,25 @@ defineSuite([
atlas = atlas && atlas.destroy();
});
- function draw(texture, textureCoordinates) {
+ function expectToRender(texture, textureCoordinates, expected) {
var x = textureCoordinates.x + textureCoordinates.width / 2.0;
var y = textureCoordinates.y + textureCoordinates.height / 2.0;
-
- var context = scene.context;
- var vs = '\
-attribute vec4 position;\n\
-void main() {\n\
- gl_PointSize = 1.0;\n\
- gl_Position = position;\n\
-}';
- var fs = '\
-uniform sampler2D u_texture;\n\
-void main() {\n\
- gl_FragColor = texture2D(u_texture, vec2(' + x + ', ' + y + '));\n\
-}';
-
- var sp = ShaderProgram.fromCache({
- context: context,
- vertexShaderSource: vs,
- fragmentShaderSource: fs,
- attributeLocations: {
- position: 0
+ var fs =
+ 'uniform sampler2D u_texture;' +
+ 'void main() {' +
+ ' gl_FragColor = texture2D(u_texture, vec2(' + x + ', ' + y + '));' +
+ '}';
+ var uniformMap = {
+ u_texture : function() {
+ return texture;
}
- });
-
- sp.allUniforms.u_texture.value = texture;
-
- var va = new VertexArray({
- context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
+ };
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 255]);
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va
- });
- command.execute(context);
-
- sp = sp.destroy();
- va = va.destroy();
-
- return context.readPixels();
+ expect({
+ context : scene.context,
+ fragmentShader : fs,
+ uniformMap : uniformMap
+ }).contextToRender(expected);
}
it('creates a single image atlas', function() {
@@ -170,7 +134,7 @@ void main() {\n\
var texture = atlas.texture;
var coords = atlas.textureCoordinates[index];
- expect(draw(texture, coords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, coords, [0, 255, 0, 255]);
});
});
@@ -210,7 +174,7 @@ void main() {\n\
var texture = atlas.texture;
var coords = atlas.textureCoordinates[index];
- expect(draw(texture, coords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, coords, [0, 255, 0, 255]);
});
});
@@ -252,7 +216,7 @@ void main() {\n\
var texture = atlas.texture;
var coords = atlas.textureCoordinates[index];
- expect(draw(texture, coords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, coords, [0, 255, 0, 255]);
});
});
@@ -311,10 +275,10 @@ void main() {\n\
var texture = atlas.texture;
var greenCoords = atlas.textureCoordinates[greenIndex];
- expect(draw(texture, greenCoords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, greenCoords, [0, 255, 0, 255]);
var blueCoords = atlas.textureCoordinates[blueIndex];
- expect(draw(texture, blueCoords)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, blueCoords, [0, 0, 255, 255]);
});
});
@@ -344,10 +308,10 @@ void main() {\n\
var c2 = atlas.textureCoordinates[bigRedIndex];
var c3 = atlas.textureCoordinates[bigBlueIndex];
- expect(draw(texture, c0)).toEqual([0, 255, 0, 255]);
- expect(draw(texture, c1)).toEqual([0, 0, 255, 255]);
- expect(draw(texture, c2)).toEqual([255, 0, 0, 255]);
- expect(draw(texture, c3)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, c0, [0, 255, 0, 255]);
+ expectToRender(texture, c1, [0, 0, 255, 255]);
+ expectToRender(texture, c2, [255, 0, 0, 255]);
+ expectToRender(texture, c3, [0, 0, 255, 255]);
});
});
@@ -431,10 +395,10 @@ void main() {\n\
var c2 = atlas.textureCoordinates[bigRedIndex];
var c3 = atlas.textureCoordinates[bigBlueIndex];
- expect(draw(texture, c0)).toEqual([0, 255, 0, 255]);
- expect(draw(texture, c1)).toEqual([0, 0, 255, 255]);
- expect(draw(texture, c2)).toEqual([255, 0, 0, 255]);
- expect(draw(texture, c3)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, c0, [0, 255, 0, 255]);
+ expectToRender(texture, c1, [0, 0, 255, 255]);
+ expectToRender(texture, c2, [255, 0, 0, 255]);
+ expectToRender(texture, c3, [0, 0, 255, 255]);
});
});
@@ -503,7 +467,7 @@ void main() {\n\
var coordinates = atlas.textureCoordinates;
var blueCoords = coordinates[blueIndex];
- expect(draw(texture, blueCoords)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, blueCoords, [0, 0, 255, 255]);
return atlas.addImage(bigGreenImage.src, bigGreenImage).then(function(greenIndex) {
expect(atlas.numberOfImages).toEqual(2);
@@ -512,10 +476,10 @@ void main() {\n\
var coordinates = atlas.textureCoordinates;
var blueCoords = coordinates[blueIndex];
- expect(draw(texture, blueCoords)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, blueCoords, [0, 0, 255, 255]);
var greenCoords = coordinates[greenIndex];
- expect(draw(texture, greenCoords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, greenCoords, [0, 255, 0, 255]);
});
});
});
@@ -556,7 +520,7 @@ void main() {\n\
var texture = atlas.texture;
var coords = atlas.textureCoordinates[index];
- expect(draw(texture, coords)).toEqual([255, 0, 0, 255]);
+ expectToRender(texture, coords, [255, 0, 0, 255]);
});
});
@@ -616,8 +580,8 @@ void main() {\n\
var greenCoords = coordinates[greenIndex];
var blueCoords = coordinates[blueIndex];
- expect(draw(texture, greenCoords)).toEqual([0, 255, 0, 255]);
- expect(draw(texture, blueCoords)).toEqual([0, 0, 255, 255]);
+ expectToRender(texture, greenCoords, [0, 255, 0, 255]);
+ expectToRender(texture, blueCoords, [0, 0, 255, 255]);
});
});
@@ -657,7 +621,7 @@ void main() {\n\
var texture = atlas.texture;
var coords = atlas.textureCoordinates[index];
- expect(draw(texture, coords)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, coords, [0, 255, 0, 255]);
});
});
@@ -682,9 +646,9 @@ void main() {\n\
var bigGreenCoordinates = atlas.textureCoordinates[bigGreenIndex];
var bigRedCoordinates = atlas.textureCoordinates[bigRedIndex];
- expect(draw(texture, blueCoordinates)).toEqual([0, 0, 255, 255]);
- expect(draw(texture, bigGreenCoordinates)).toEqual([0, 255, 0, 255]);
- expect(draw(texture, bigRedCoordinates)).toEqual([255, 0, 0, 255]);
+ expectToRender(texture, blueCoordinates, [0, 0, 255, 255]);
+ expectToRender(texture, bigGreenCoordinates, [0, 255, 0, 255]);
+ expectToRender(texture, bigRedCoordinates, [255, 0, 0, 255]);
});
});
@@ -712,8 +676,8 @@ void main() {\n\
var blueCoordinates = coordinates[blueIndex];
var greenCoordinates = coordinates[greenIndex];
- expect(draw(texture, blueCoordinates)).toEqual([0, 0, 255, 255]);
- expect(draw(texture, greenCoordinates)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, blueCoordinates, [0, 0, 255, 255]);
+ expectToRender(texture, greenCoordinates, [0, 255, 0, 255]);
});
});
});
@@ -850,8 +814,8 @@ void main() {\n\
var blueCoordinates = coordinates[blueIndex];
var greenCoordinates = coordinates[greenIndex];
- expect(draw(texture, blueCoordinates)).toEqual([0, 0, 255, 255]);
- expect(draw(texture, greenCoordinates)).toEqual([0, 255, 0, 255]);
+ expectToRender(texture, blueCoordinates, [0, 0, 255, 255]);
+ expectToRender(texture, greenCoordinates, [0, 255, 0, 255]);
// after loading 'Blue Image', further adds should not call the function
diff --git a/Specs/Scene/ViewportQuadSpec.js b/Specs/Scene/ViewportQuadSpec.js
index 7184e72cf57f..9551d70cebd9 100644
--- a/Specs/Scene/ViewportQuadSpec.js
+++ b/Specs/Scene/ViewportQuadSpec.js
@@ -80,15 +80,15 @@ defineSuite([
it('does not render when show is false', function() {
viewportQuad.show = false;
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(viewportQuad);
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
});
it('renders material', function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(viewportQuad);
- expect(scene.renderForSpecs()).not.toEqual([0, 0, 0, 255]);
+ expect(scene).notToRender([0, 0, 0, 255]);
});
it('renders user created texture', function() {
@@ -103,9 +103,9 @@ defineSuite([
pollToPromise(function() {
return viewportQuad.material._loadedImages.length !== 0;
}).then(function() {
- expect(scene.renderForSpecs()).toEqual([0, 0, 0, 255]);
+ expect(scene).toRender([0, 0, 0, 255]);
scene.primitives.add(viewportQuad);
- expect(scene.renderForSpecs()).toEqual([255, 0, 0, 255]);
+ expect(scene).toRender([255, 0, 0, 255]);
});
});
diff --git a/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js b/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
index 4ec0ccb10394..779bd67a3a73 100644
--- a/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
+++ b/Specs/Widgets/CesiumWidget/CesiumWidgetSpec.js
@@ -13,6 +13,7 @@ defineSuite([
'Scene/SkyBox',
'Scene/TileCoordinatesImageryProvider',
'Specs/DomEventSimulator',
+ 'Specs/getWebGLStub',
'Specs/pollToPromise'
], function(
CesiumWidget,
@@ -28,6 +29,7 @@ defineSuite([
SkyBox,
TileCoordinatesImageryProvider,
DomEventSimulator,
+ getWebGLStub,
pollToPromise) {
'use strict';
@@ -54,6 +56,9 @@ defineSuite([
options = defaultValue(options, {});
options.contextOptions = defaultValue(options.contextOptions, {});
options.contextOptions.webgl = defaultValue(options.contextOptions.webgl, {});
+ if (!!window.webglStub) {
+ options.contextOptions.getWebGLStub = getWebGLStub;
+ }
return new CesiumWidget(container, options);
}
diff --git a/Specs/Widgets/InfoBox/InfoBoxSpec.js b/Specs/Widgets/InfoBox/InfoBoxSpec.js
index 895ea22b1383..a6c387d638d7 100644
--- a/Specs/Widgets/InfoBox/InfoBoxSpec.js
+++ b/Specs/Widgets/InfoBox/InfoBoxSpec.js
@@ -61,7 +61,7 @@ defineSuite([
it('constructor works with string id container', function() {
infoBox = new InfoBox('testContainer');
- expect(infoBox.container).toBe(testContainer);
+ expect(infoBox.container.id).toBe(testContainer.id);
});
it('throws if container is undefined', function() {
diff --git a/Specs/Widgets/NavigationHelpButton/NavigationHelpButtonSpec.js b/Specs/Widgets/NavigationHelpButton/NavigationHelpButtonSpec.js
index 9ad56dfde2f9..8ebbcbfd166f 100644
--- a/Specs/Widgets/NavigationHelpButton/NavigationHelpButtonSpec.js
+++ b/Specs/Widgets/NavigationHelpButton/NavigationHelpButtonSpec.js
@@ -1,10 +1,12 @@
/*global defineSuite*/
defineSuite([
'Widgets/NavigationHelpButton/NavigationHelpButton',
+ 'Core/defined',
'Core/FeatureDetection',
'Specs/DomEventSimulator'
], function(
NavigationHelpButton,
+ defined,
FeatureDetection,
DomEventSimulator) {
'use strict';
@@ -17,7 +19,7 @@ defineSuite([
var widget = new NavigationHelpButton({
container : 'testContainer'
});
- expect(widget.container).toBe(container);
+ expect(widget.container.id).toBe(container.id);
expect(widget.isDestroyed()).toEqual(false);
widget.destroy();
diff --git a/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogSpec.js b/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogSpec.js
index 038fb938bdf7..74d52b97ec10 100644
--- a/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogSpec.js
+++ b/Specs/Widgets/PerformanceWatchdog/PerformanceWatchdogSpec.js
@@ -25,7 +25,7 @@ defineSuite([
container : 'testContainer',
scene : scene
});
- expect(widget.container).toBe(container);
+ expect(widget.container.id).toEqual(container.id);
expect(widget.isDestroyed()).toEqual(false);
widget.destroy();
diff --git a/Specs/Widgets/SceneModePicker/SceneModePickerSpec.js b/Specs/Widgets/SceneModePicker/SceneModePickerSpec.js
index f9be6406da5b..29e62e8350ad 100644
--- a/Specs/Widgets/SceneModePicker/SceneModePickerSpec.js
+++ b/Specs/Widgets/SceneModePicker/SceneModePickerSpec.js
@@ -1,11 +1,13 @@
/*global defineSuite*/
defineSuite([
'Widgets/SceneModePicker/SceneModePicker',
+ 'Core/defined',
'Core/FeatureDetection',
'Specs/createScene',
'Specs/DomEventSimulator'
], function(
SceneModePicker,
+ defined,
FeatureDetection,
createScene,
DomEventSimulator) {
@@ -27,7 +29,7 @@ defineSuite([
document.body.appendChild(container);
var widget = new SceneModePicker('testContainer', scene);
- expect(widget.container).toBe(container);
+ expect(widget.container.id).toBe(container.id);
expect(widget.isDestroyed()).toEqual(false);
widget.destroy();
diff --git a/Specs/Widgets/Viewer/viewerPerformanceWatchdogMixinSpec.js b/Specs/Widgets/Viewer/viewerPerformanceWatchdogMixinSpec.js
index 4198fc480aae..6add92c3a465 100644
--- a/Specs/Widgets/Viewer/viewerPerformanceWatchdogMixinSpec.js
+++ b/Specs/Widgets/Viewer/viewerPerformanceWatchdogMixinSpec.js
@@ -1,12 +1,12 @@
/*global defineSuite*/
defineSuite([
+ 'Widgets/Viewer/viewerPerformanceWatchdogMixin',
'Specs/createViewer',
- 'Widgets/PerformanceWatchdog/PerformanceWatchdog',
- 'Widgets/Viewer/viewerPerformanceWatchdogMixin'
+ 'Widgets/PerformanceWatchdog/PerformanceWatchdog'
], function(
+ viewerPerformanceWatchdogMixin,
createViewer,
- PerformanceWatchdog,
- viewerPerformanceWatchdogMixin) {
+ PerformanceWatchdog) {
'use strict';
var container;
diff --git a/Specs/addDefaultMatchers.js b/Specs/addDefaultMatchers.js
index 5c97f71d4762..cb8e2df2d669 100644
--- a/Specs/addDefaultMatchers.js
+++ b/Specs/addDefaultMatchers.js
@@ -1,14 +1,34 @@
/*global define*/
define([
'./equals',
+ 'Core/Cartesian2',
+ 'Core/defaultValue',
'Core/defined',
'Core/DeveloperError',
- 'Core/RuntimeError'
+ 'Core/Math',
+ 'Core/PrimitiveType',
+ 'Core/RuntimeError',
+ 'Renderer/Buffer',
+ 'Renderer/BufferUsage',
+ 'Renderer/ClearCommand',
+ 'Renderer/DrawCommand',
+ 'Renderer/ShaderProgram',
+ 'Renderer/VertexArray'
], function(
equals,
+ Cartesian2,
+ defaultValue,
defined,
DeveloperError,
- RuntimeError) {
+ CesiumMath,
+ PrimitiveType,
+ RuntimeError,
+ Buffer,
+ BufferUsage,
+ ClearCommand,
+ DrawCommand,
+ ShaderProgram,
+ VertexArray) {
'use strict';
function createMissingFunctionMessageFunction(item, actualPrototype, expectedInterfacePrototype) {
@@ -72,7 +92,7 @@ define([
return {
toBeGreaterThanOrEqualTo : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected) {
+ compare : function(actual, expected) {
return { pass : actual >= expected };
}
};
@@ -80,7 +100,7 @@ define([
toBeLessThanOrEqualTo : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected) {
+ compare : function(actual, expected) {
return { pass : actual <= expected };
}
};
@@ -88,7 +108,7 @@ define([
toBeBetween : function(util, customEqualityTesters) {
return {
- compare: function(actual, lower, upper) {
+ compare : function(actual, lower, upper) {
if (lower > upper) {
var tmp = upper;
upper = lower;
@@ -101,7 +121,7 @@ define([
toStartWith : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected) {
+ compare : function(actual, expected) {
return { pass : actual.slice(0, expected.length) === expected };
}
};
@@ -109,7 +129,7 @@ define([
toEndWith : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected) {
+ compare : function(actual, expected) {
return { pass : actual.slice(-expected.length) === expected };
}
};
@@ -117,7 +137,7 @@ define([
toEqual : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected) {
+ compare : function(actual, expected) {
return { pass : equals(util, customEqualityTesters, actual, expected) };
}
};
@@ -125,7 +145,7 @@ define([
toEqualEpsilon : function(util, customEqualityTesters) {
return {
- compare: function(actual, expected, epsilon) {
+ compare : function(actual, expected, epsilon) {
function equalityTester(a, b) {
if (Array.isArray(a) && Array.isArray(b)) {
if (a.length !== b.length) {
@@ -206,8 +226,189 @@ define([
};
},
- toThrow : function(expectedConstructor) {
- throw new Error('Do not use toThrow. Use toThrowDeveloperError or toThrowRuntimeError instead.');
+ toRender : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return renderEquals(util, customEqualityTesters, actual, expected, true);
+ }
+ };
+ },
+
+ notToRender : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return renderEquals(util, customEqualityTesters, actual, expected, false);
+ }
+ };
+ },
+
+ toRenderAndCall : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ var actualRgba = renderAndReadPixels(actual);
+
+ var webglStub = !!window.webglStub;
+ if (!webglStub) {
+ // The callback may have expectations that fail, which still makes the
+ // spec fail, as we desired, even though this matcher sets pass to true.
+ var callback = expected;
+ callback(actualRgba);
+ }
+
+ return {
+ pass : true
+ };
+ }
+ };
+ },
+
+ toPickPrimitive : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return pickPrimitiveEquals(actual, expected);
+ }
+ };
+ },
+
+ notToPick : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return pickPrimitiveEquals(actual, undefined);
+ }
+ };
+ },
+
+ toPickAndCall : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ var scene = actual;
+ var result = scene.pick(new Cartesian2(0, 0));
+
+ var webglStub = !!window.webglStub;
+ if (!webglStub) {
+ // The callback may have expectations that fail, which still makes the
+ // spec fail, as we desired, even though this matcher sets pass to true.
+ var callback = expected;
+ callback(result);
+ }
+
+ return {
+ pass : true
+ };
+ }
+ };
+ },
+
+ toDrillPickAndCall : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ var scene = actual;
+ var pickedObjects = scene.drillPick(new Cartesian2(0, 0));
+
+ var webglStub = !!window.webglStub;
+ if (!webglStub) {
+ // The callback may have expectations that fail, which still makes the
+ // spec fail, as we desired, even though this matcher sets pass to true.
+ var callback = expected;
+ callback(pickedObjects);
+ }
+
+ return {
+ pass : true
+ };
+ }
+ };
+ },
+
+ toReadPixels : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ var context;
+ var framebuffer;
+ var epsilon = 0;
+
+ var options = actual;
+ if (defined(options.context)) {
+ // options were passed to to a framebuffer
+ context = options.context;
+ framebuffer = options.framebuffer;
+ epsilon = defaultValue(options.epsilon, epsilon);
+ } else {
+ context = options;
+ }
+
+ var rgba = context.readPixels({
+ framebuffer : framebuffer
+ });
+
+ var pass = true;
+ var message;
+
+ var webglStub = !!window.webglStub;
+ if (!webglStub) {
+ if (!CesiumMath.equalsEpsilon(rgba[0], expected[0], 0, epsilon) ||
+ !CesiumMath.equalsEpsilon(rgba[1], expected[1], 0, epsilon) ||
+ !CesiumMath.equalsEpsilon(rgba[2], expected[2], 0, epsilon) ||
+ !CesiumMath.equalsEpsilon(rgba[3], expected[3], 0, epsilon)) {
+ pass = false;
+ if (epsilon === 0) {
+ message = 'Expected context to render ' + expected + ', but rendered: ' + rgba;
+ } else {
+ message = 'Expected context to render ' + expected + ' with epsilon = ' + epsilon + ', but rendered: ' + rgba;
+ }
+ }
+ }
+
+ return {
+ pass : pass,
+ message : message
+ };
+ }
+ };
+ },
+
+ notToReadPixels : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ var context = actual;
+ var rgba = context.readPixels();
+
+ var pass = true;
+ var message;
+
+ var webglStub = !!window.webglStub;
+ if (!webglStub) {
+ if ((rgba[0] === expected[0]) &&
+ (rgba[1] === expected[1]) &&
+ (rgba[2] === expected[2]) &&
+ (rgba[3] === expected[3])) {
+ pass = false;
+ message = 'Expected context not to render ' + expected + ', but rendered: ' + rgba;
+ }
+ }
+
+ return {
+ pass : pass,
+ message : message
+ };
+ }
+ };
+ },
+
+ contextToRender : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return expectContextToRender(actual, expected, true);
+ }
+ };
+ },
+
+ notContextToRender : function(util, customEqualityTesters) {
+ return {
+ compare : function(actual, expected) {
+ return expectContextToRender(actual, expected, false);
+ }
+ };
},
toThrowDeveloperError : makeThrowFunction(debug, DeveloperError, 'DeveloperError'),
@@ -216,6 +417,203 @@ define([
};
}
+ function renderAndReadPixels(options) {
+ var scene;
+
+ if (defined(options.scene)) {
+ // options were passed to render the scene at a given time or prime shadow map
+ scene = options.scene;
+ var time = options.time;
+
+ scene.initializeFrame();
+ if (defined(options.primeShadowMap)) {
+ scene.render(time); // Computes shadow near/far for next frame
+ }
+ scene.render(time);
+ } else {
+ scene = options;
+ scene.initializeFrame();
+ scene.render();
+ }
+
+ return scene.context.readPixels();
+ }
+
+ function renderEquals(util, customEqualityTesters, actual, expected, expectEqual) {
+ var actualRgba = renderAndReadPixels(actual);
+
+ // When the WebGL stub is used, all WebGL function calls are noops so
+ // the expectation is not verified. This allows running all the WebGL
+ // tests, to exercise as much Cesium code as possible, even if the system
+ // doesn't have a WebGL implementation or a reliable one.
+ if (!!window.webglStub) {
+ return {
+ pass : true
+ };
+ }
+
+ var eq = equals(util, customEqualityTesters, actualRgba, expected);
+ var pass = expectEqual ? eq : !eq;
+
+ var message;
+ if (!pass) {
+ message = 'Expected ' + (expectEqual ? '' : 'not ') + 'to render [' + expected + '], but actually rendered [' + actualRgba + '].';
+ }
+
+ return {
+ pass : pass,
+ message : message
+ };
+ }
+
+ function pickPrimitiveEquals(actual, expected) {
+ var scene = actual;
+ var result = scene.pick(new Cartesian2(0, 0));
+
+ if (!!window.webglStub) {
+ return {
+ pass : true
+ };
+ }
+
+ var pass = true;
+ var message;
+
+ if (defined(expected)) {
+ pass = (result.primitive === expected);
+ } else {
+ pass = !defined(result);
+ }
+
+ if (!pass) {
+ message = 'Expected to pick ' + expected + ', but picked: ' + result;
+ }
+
+ return {
+ pass : pass,
+ message : message
+ };
+ }
+
+ function expectContextToRender(actual, expected, expectEqual) {
+ var options = actual;
+ var context = options.context;
+ var vs = options.vertexShader;
+ var fs = options.fragmentShader;
+ var sp = options.shaderProgram;
+ var uniformMap = options.uniformMap;
+ var modelMatrix = options.modelMatrix;
+ var depth = defaultValue(options.depth, 0.0);
+ var clear = defaultValue(options.clear, true);
+
+ if (!defined(expected)) {
+ expected = [255, 255, 255, 255];
+ }
+
+ if (!defined(context)) {
+ throw new DeveloperError('options.context is required.');
+ }
+
+ if (!defined(fs) && !defined(sp)) {
+ throw new DeveloperError('options.fragmentShader or options.shaderProgram is required.');
+ }
+
+ if (defined(fs) && defined(sp)) {
+ throw new DeveloperError('Both options.fragmentShader and options.shaderProgram can not be used at the same time.');
+ }
+
+ if (defined(vs) && defined(sp)) {
+ throw new DeveloperError('Both options.vertexShader and options.shaderProgram can not be used at the same time.');
+ }
+
+ if (!defined(sp)) {
+ if (!defined(vs)) {
+ vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
+ }
+ sp = ShaderProgram.fromCache({
+ context : context,
+ vertexShaderSource : vs,
+ fragmentShaderSource : fs,
+ attributeLocations: {
+ position: 0
+ }
+ });
+ }
+
+ var va = new VertexArray({
+ context : context,
+ attributes : [{
+ index : 0,
+ vertexBuffer : Buffer.createVertexBuffer({
+ context : context,
+ typedArray : new Float32Array([0.0, 0.0, depth, 1.0]),
+ usage : BufferUsage.STATIC_DRAW
+ }),
+ componentsPerAttribute : 4
+ }]
+ });
+
+ var webglStub = !!window.webglStub;
+
+ if (clear) {
+ ClearCommand.ALL.execute(context);
+
+ var clearedRgba = context.readPixels();
+ if (!webglStub) {
+ var expectedAlpha = context.options.webgl.alpha ? 0 : 255;
+ if ((clearedRgba[0] !== 0) ||
+ (clearedRgba[1] !== 0) ||
+ (clearedRgba[2] !== 0) ||
+ (clearedRgba[3] !== expectedAlpha)) {
+ return {
+ pass : false,
+ message : 'After clearing the framebuffer, expected context to render [0, 0, 0, ' + expectedAlpha + '], but rendered: ' + clearedRgba
+ };
+ }
+ }
+ }
+
+ var command = new DrawCommand({
+ primitiveType : PrimitiveType.POINTS,
+ shaderProgram : sp,
+ vertexArray : va,
+ uniformMap : uniformMap,
+ modelMatrix : modelMatrix
+ });
+ command.execute(context);
+ var rgba = context.readPixels();
+ if (!webglStub) {
+ if (expectEqual) {
+ if ((rgba[0] !== expected[0]) ||
+ (rgba[1] !== expected[1]) ||
+ (rgba[2] !== expected[2]) ||
+ (rgba[3] !== expected[3])) {
+ return {
+ pass : false,
+ message : 'Expected context to render ' + expected + ', but rendered: ' + rgba
+ };
+ }
+ } else {
+ if ((rgba[0] === expected[0]) &&
+ (rgba[1] === expected[1]) &&
+ (rgba[2] === expected[2]) &&
+ (rgba[3] === expected[3])) {
+ return {
+ pass : false,
+ message : 'Expected context not to render ' + expected + ', but rendered: ' + rgba
+ };
+ }
+ }
+ }
+
+ sp = sp.destroy();
+ va = va.destroy();
+
+ return {
+ pass : true
+ };
+ }
+
return function(debug) {
return function() {
this.addMatchers(createDefaultMatchers(debug));
diff --git a/Specs/createContext.js b/Specs/createContext.js
index 0f69f84bad04..d12d5186a3c5 100644
--- a/Specs/createContext.js
+++ b/Specs/createContext.js
@@ -2,50 +2,32 @@
define([
'Core/clone',
'Core/defaultValue',
- 'Core/defined',
- 'Core/PrimitiveType',
- 'Core/queryToObject',
- 'Renderer/Buffer',
- 'Renderer/BufferUsage',
- 'Renderer/ClearCommand',
'Renderer/Context',
- 'Renderer/DrawCommand',
- 'Renderer/ShaderProgram',
- 'Renderer/VertexArray',
'Specs/createCanvas',
'Specs/createFrameState',
- 'Specs/destroyCanvas'
+ 'Specs/getWebGLStub'
], function(
clone,
defaultValue,
- defined,
- PrimitiveType,
- queryToObject,
- Buffer,
- BufferUsage,
- ClearCommand,
Context,
- DrawCommand,
- ShaderProgram,
- VertexArray,
createCanvas,
createFrameState,
- destroyCanvas) {
+ getWebGLStub) {
'use strict';
function createContext(options, canvasWidth, canvasHeight) {
// clone options so we can change properties
options = clone(defaultValue(options, {}));
options.webgl = clone(defaultValue(options.webgl, {}));
- options.webgl.alpha = defaultValue(options.webgl.alpha, true);
options.webgl.antialias = defaultValue(options.webgl.antialias, false);
-
+ if (!!window.webglStub) {
+ options.getWebGLStub = getWebGLStub;
+ }
var canvas = createCanvas(canvasWidth, canvasHeight);
var context = new Context(canvas, options);
- var parameters = queryToObject(window.location.search.substring(1));
- if (defined(parameters.webglValidation)) {
+ if (!!window.webglValidation) {
context.validateShaderProgram = true;
context.validateFramebuffer = true;
context.logShaderCompilation = true;
@@ -57,49 +39,10 @@ define([
// Add function for test
context.destroyForSpecs = function() {
- destroyCanvas(context.canvas);
+ document.body.removeChild(context.canvas);
return context.destroy();
};
- context.verifyDrawForSpecs = function(fs, uniformMap, modelMatrix) {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
-
- var sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
-
- var va = new VertexArray({
- context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0, 0, 0, 1]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
-
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va,
- uniformMap : uniformMap,
- modelMatrix : modelMatrix
- });
- command.execute(context);
- expect(context.readPixels()).toEqual([255, 255, 255, 255]);
-
- sp = sp.destroy();
- va = va.destroy();
- };
-
return context;
}
diff --git a/Specs/createScene.js b/Specs/createScene.js
index 6b070ae6772a..cce1edaf1eb7 100644
--- a/Specs/createScene.js
+++ b/Specs/createScene.js
@@ -6,7 +6,7 @@ define([
'Core/defined',
'Scene/Scene',
'Specs/createCanvas',
- 'Specs/destroyCanvas'
+ 'Specs/getWebGLStub'
], function(
Cartesian2,
clone,
@@ -14,7 +14,7 @@ define([
defined,
Scene,
createCanvas,
- destroyCanvas) {
+ getWebGLStub) {
'use strict';
function createScene(options) {
@@ -33,10 +33,13 @@ define([
contextOptions.webgl = defaultValue(contextOptions.webgl, {});
contextOptions.webgl.antialias = defaultValue(contextOptions.webgl.antialias, false);
contextOptions.webgl.stencil = defaultValue(contextOptions.webgl.stencil, true);
+ if (!!window.webglStub) {
+ contextOptions.getWebGLStub = getWebGLStub;
+ }
var scene = new Scene(options);
- if (window.webglValidation) {
+ if (!!window.webglValidation) {
var context = scene.context;
context.validateShaderProgram = true;
context.validateFramebuffer = true;
@@ -46,19 +49,14 @@ define([
// Add functions for test
scene.destroyForSpecs = function() {
- var canvas = scene.canvas;
- scene.destroy();
- destroyCanvas(canvas);
+ var canvas = this.canvas;
+ this.destroy();
+ document.body.removeChild(canvas);
};
scene.renderForSpecs = function(time) {
- scene.initializeFrame();
- scene.render(time);
- return scene.context.readPixels();
- };
-
- scene.pickForSpecs = function() {
- return scene.pick(new Cartesian2(0, 0));
+ this.initializeFrame();
+ this.render(time);
};
scene.rethrowRenderErrors = defaultValue(options.rethrowRenderErrors, true);
diff --git a/Specs/createViewer.js b/Specs/createViewer.js
index 2e063697f43e..912d75f8cc3d 100644
--- a/Specs/createViewer.js
+++ b/Specs/createViewer.js
@@ -1,16 +1,21 @@
/*global define*/
define([
'Core/defaultValue',
- 'Widgets/Viewer/Viewer'
+ 'Widgets/Viewer/Viewer',
+ 'Specs/getWebGLStub'
], function(
defaultValue,
- Viewer) {
+ Viewer,
+ getWebGLStub) {
'use strict';
function createViewer(container, options) {
options = defaultValue(options, {});
options.contextOptions = defaultValue(options.contextOptions, {});
options.contextOptions.webgl = defaultValue(options.contextOptions.webgl, {});
+ if (!!window.webglStub) {
+ options.contextOptions.getWebGLStub = getWebGLStub;
+ }
return new Viewer(container, options);
}
diff --git a/Specs/customizeJasmine.js b/Specs/customizeJasmine.js
index ec6c965d2630..e857b01912a6 100644
--- a/Specs/customizeJasmine.js
+++ b/Specs/customizeJasmine.js
@@ -9,7 +9,7 @@ define([
equalsMethodEqualityTester) {
"use strict";
- return function (env, includedCategory, excludedCategory, webglValidation, release) {
+ return function (env, includedCategory, excludedCategory, webglValidation, webglStub, release) {
function defineSuite(deps, name, suite, categories, focus) {
/*global define,describe,fdescribe*/
if (typeof suite === 'object' || typeof suite === 'string') {
@@ -137,6 +137,10 @@ define([
window.webglValidation = true;
}
+ if (webglStub) {
+ window.webglStub = true;
+ }
+
//env.catchExceptions(true);
env.beforeEach(function () {
diff --git a/Specs/destroyCanvas.js b/Specs/destroyCanvas.js
deleted file mode 100644
index 207d3d635200..000000000000
--- a/Specs/destroyCanvas.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/*global define*/
-define(function() {
- 'use strict';
-
- function destroyCanvas(canvas) {
- if (canvas) {
- document.body.removeChild(canvas);
- }
- }
-
- return destroyCanvas;
-});
diff --git a/Specs/getWebGLStub.js b/Specs/getWebGLStub.js
new file mode 100644
index 000000000000..00f5608433ce
--- /dev/null
+++ b/Specs/getWebGLStub.js
@@ -0,0 +1,300 @@
+/*global define*/
+define([
+ 'Core/clone',
+ 'Core/defaultValue',
+ 'Core/defined',
+ 'Core/DeveloperError',
+ 'Core/WebGLConstants'
+ ], function(
+ clone,
+ defaultValue,
+ defined,
+ DeveloperError,
+ WebGLConstants) {
+ 'use strict';
+
+ function getWebGLStub(canvas, options) {
+ var stub = clone(WebGLConstants);
+
+ stub.canvas = canvas;
+ stub.drawingBufferWidth = Math.max(canvas.width, 1);
+ stub.drawingBufferHeight = Math.max(canvas.height, 1);
+
+ stub.activeTexture = noop;
+ stub.attachShader = noop;
+ stub.bindAttribLocation = noop;
+ stub.bindBuffer = noop;
+ stub.bindFramebuffer = noop;
+ stub.bindRenderbuffer = noop;
+ stub.bindTexture = noop;
+ stub.blendColor = noop;
+ stub.blendEquation = noop;
+ stub.blendEquationSeparate = noop;
+ stub.blendFunc = noop;
+ stub.blendFuncSeparate = noop;
+ stub.bufferData = noop;
+ stub.bufferSubData = noop;
+ stub.checkFramebufferStatus = checkFramebufferStatusStub;
+ stub.clear = noop;
+ stub.clearColor = noop;
+ stub.clearDepth = noop;
+ stub.clearStencil = noop;
+ stub.colorMask = noop;
+ stub.compileShader = noop;
+ stub.compressedTexImage2D = noop;
+ stub.compressedTexSubImage2D = noop;
+ stub.copyTexImage2D = noop;
+ stub.copyTexSubImage2D = noop;
+ stub.createBuffer = createStub;
+ stub.createFramebuffer = createStub;
+ stub.createProgram = createStub;
+ stub.createRenderbuffer = createStub;
+ stub.createShader = createStub;
+ stub.createTexture = createStub;
+ stub.cullFace = noop;
+ stub.deleteBuffer = noop;
+ stub.deleteFramebuffer = noop;
+ stub.deleteProgram = noop;
+ stub.deleteRenderbuffer = noop;
+ stub.deleteShader = noop;
+ stub.deleteTexture = noop;
+ stub.depthFunc = noop;
+ stub.depthMask = noop;
+ stub.depthRange = noop;
+ stub.detachShader = noop;
+ stub.disable = noop;
+ stub.disableVertexAttribArray = noop;
+ stub.drawArrays = noop;
+ stub.drawElements = noop;
+ stub.enable = noop;
+ stub.enableVertexAttribArray = noop;
+ stub.finish = noop;
+ stub.flush = noop;
+ stub.framebufferRenderbuffer = noop;
+ stub.framebufferTexture2D = noop;
+ stub.frontFace = noop;
+ stub.generateMipmap = noop;
+ stub.getActiveAttrib = getStub;
+ stub.getActiveUniform = getStub;
+ stub.getAttachedShaders = getStubWarning;
+ stub.getAttribLocation = getStub;
+ stub.getBufferParameter = getStubWarning;
+ stub.getContextAttributes = getContextAttributesStub(options);
+ stub.getError = getErrorStub;
+ stub.getExtension = getExtensionStub;
+ stub.getFramebufferAttachmentParameter = getStubWarning;
+ stub.getParameter = getParameterStub(options);
+ stub.getProgramParameter = getProgramParameterStub;
+ stub.getProgramInfoLog = getStub;
+ stub.getRenderbufferParameter = getStubWarning;
+ stub.getShaderParameter = getShaderParameterStub;
+ stub.getShaderInfoLog = getStub;
+ stub.getShaderPrecisionFormat = getShaderPrecisionStub;
+ stub.getShaderSource = getStubWarning;
+ stub.getSupportedExtensions = getStubWarning;
+ stub.getTexParameter = getStubWarning;
+ stub.getUniform = getStub;
+ stub.getUniformLocation = getStub;
+ stub.getVertexAttrib = getStubWarning;
+ stub.getVertexAttribOffset = getStubWarning;
+ stub.hint = noop;
+ stub.isBuffer = getStubWarning;
+ stub.isContextLost = getStubWarning;
+ stub.isEnabled = getStubWarning;
+ stub.isFramebuffer = getStubWarning;
+ stub.isProgram = getStubWarning;
+ stub.isRenderbuffer = getStubWarning;
+ stub.isShader = getStubWarning;
+ stub.isTexture = getStubWarning;
+ stub.lineWidth = noop;
+ stub.linkProgram = noop;
+ stub.pixelStorei = noop;
+ stub.polygonOffset = noop;
+ stub.readPixels = readPixelsStub;
+ stub.renderbufferStorage = noop;
+ stub.sampleCoverage = noop;
+ stub.scissor = noop;
+ stub.shaderSource = noop;
+ stub.stencilFunc = noop;
+ stub.stencilFuncSeparate = noop;
+ stub.stencilMask = noop;
+ stub.stencilMaskSeparate = noop;
+ stub.stencilOp = noop;
+ stub.stencilOpSeparate = noop;
+ stub.texParameterf = noop;
+ stub.texParameteri = noop;
+ stub.texImage2D = noop;
+ stub.texSubImage2D = noop;
+ stub.uniform1f = noop;
+ stub.uniform1fv = noop;
+ stub.uniform1i = noop;
+ stub.uniform1iv = noop;
+ stub.uniform2f = noop;
+ stub.uniform2fv = noop;
+ stub.uniform2i = noop;
+ stub.uniform2iv = noop;
+ stub.uniform3f = noop;
+ stub.uniform3fv = noop;
+ stub.uniform3i = noop;
+ stub.uniform3iv = noop;
+ stub.uniform4f = noop;
+ stub.uniform4fv = noop;
+ stub.uniform4i = noop;
+ stub.uniform4iv = noop;
+ stub.uniformMatrix2fv = noop;
+ stub.uniformMatrix3fv = noop;
+ stub.uniformMatrix4fv = noop;
+ stub.useProgram = noop;
+ stub.validateProgram = noop;
+ stub.vertexAttrib1f = noop;
+ stub.vertexAttrib1fv = noop;
+ stub.vertexAttrib2f = noop;
+ stub.vertexAttrib2fv = noop;
+ stub.vertexAttrib3f = noop;
+ stub.vertexAttrib3fv = noop;
+ stub.vertexAttrib4f = noop;
+ stub.vertexAttrib4fv = noop;
+ stub.vertexAttribPointer = noop;
+ stub.viewport = noop;
+
+ return stub;
+ }
+
+ function noop() {
+ }
+
+ function createStub() {
+ return {};
+ }
+
+ function getStub() {
+ return {};
+ }
+
+ function getStubWarning() {
+ //>>includeStart('debug', pragmas.debug);
+ throw new DeveloperError('A stub for this get/is function is not defined. Can it use getStub() or does it need a new one?');
+ //>>includeEnd('debug');
+ }
+
+ function checkFramebufferStatusStub(target) {
+ return WebGLConstants.FRAMEBUFFER_COMPLETE;
+ }
+
+ function getContextAttributesStub(options) {
+ var contextAttributes = {
+ alpha : defaultValue(options.alpha, true),
+ depth : defaultValue(options.depth, true),
+ stencil : defaultValue(options.stencil, false),
+ antialias : defaultValue(options.antialias, true),
+ premultipliedAlpha : defaultValue(options.premultipliedAlpha, true),
+ preserveDrawingBuffer : defaultValue(options.preserveDrawingBuffer, false),
+ preferLowPowerToHighPerformance : defaultValue(options.preferLowPowerToHighPerformance, false),
+ failIfMajorPerformanceCaveat : defaultValue(options.failIfMajorPerformanceCaveat, false)
+ };
+
+ return function() {
+ return contextAttributes;
+ };
+ }
+
+ function getErrorStub() {
+ return WebGLConstants.NO_ERROR;
+ }
+
+ function getExtensionStub(name) {
+ // No extensions are stubbed.
+ return null;
+ }
+
+ function getParameterStub(options) {
+ // These are not the minimum maximum; instead, they are typical maximums.
+ var parameterStubValues = {};
+ parameterStubValues[WebGLConstants.STENCIL_BITS] = options.stencil ? 8 : 0;
+ parameterStubValues[WebGLConstants.MAX_COMBINED_TEXTURE_IMAGE_UNITS] = 32;
+ parameterStubValues[WebGLConstants.MAX_CUBE_MAP_TEXTURE_SIZE] = 16384;
+ parameterStubValues[WebGLConstants.MAX_FRAGMENT_UNIFORM_VECTORS] = 1024;
+ parameterStubValues[WebGLConstants.MAX_TEXTURE_IMAGE_UNITS] = 16;
+ parameterStubValues[WebGLConstants.MAX_RENDERBUFFER_SIZE] = 16384;
+ parameterStubValues[WebGLConstants.MAX_TEXTURE_SIZE] = 16384;
+ parameterStubValues[WebGLConstants.MAX_VARYING_VECTORS] = 30;
+ parameterStubValues[WebGLConstants.MAX_VERTEX_ATTRIBS] = 16;
+ parameterStubValues[WebGLConstants.MAX_VERTEX_TEXTURE_IMAGE_UNITS] = 16;
+ parameterStubValues[WebGLConstants.MAX_VERTEX_UNIFORM_VECTORS] = 4096;
+ parameterStubValues[WebGLConstants.ALIASED_LINE_WIDTH_RANGE] = [1, 1];
+ parameterStubValues[WebGLConstants.ALIASED_POINT_SIZE_RANGE] = [1, 1024];
+ parameterStubValues[WebGLConstants.MAX_VIEWPORT_DIMS] = [16384, 16384];
+ parameterStubValues[WebGLConstants.MAX_TEXTURE_MAX_ANISOTROPY_EXT] = 16; // Assuming extension
+ parameterStubValues[WebGLConstants.MAX_DRAW_BUFFERS] = 8; // Assuming extension
+ parameterStubValues[WebGLConstants.MAX_COLOR_ATTACHMENTS] = 8; // Assuming extension
+
+ return function(pname) {
+ var value = parameterStubValues[pname];
+
+ //>>includeStart('debug', pragmas.debug);
+ if (!defined(value)) {
+ throw new DeveloperError('A WebGL parameter stub for ' + pname + ' is not defined. Add it.');
+ }
+ //>>includeEnd('debug');
+
+ return value;
+ };
+ }
+
+ function getProgramParameterStub(program, pname) {
+ if ((pname === WebGLConstants.LINK_STATUS) || (pname === WebGLConstants.VALIDATE_STATUS)) {
+ return true;
+ }
+
+ if ((pname === WebGLConstants.ACTIVE_UNIFORMS) || (pname === WebGLConstants.ACTIVE_ATTRIBUTES)) {
+ return 0;
+ }
+
+ //>>includeStart('debug', pragmas.debug);
+ throw new DeveloperError('A WebGL parameter stub for ' + pname + ' is not defined. Add it.');
+ //>>includeEnd('debug');
+ }
+
+ function getShaderParameterStub(shader, pname) {
+ //>>includeStart('debug', pragmas.debug);
+ if (pname !== WebGLConstants.COMPILE_STATUS) {
+ throw new DeveloperError('A WebGL parameter stub for ' + pname + ' is not defined. Add it.');
+ }
+ //>>includeEnd('debug');
+
+ return true;
+ }
+
+ function getShaderPrecisionStub(shadertype, precisiontype) {
+ //>>includeStart('debug', pragmas.debug);
+ if (shadertype !== WebGLConstants.FRAGMENT_SHADER) {
+ throw new DeveloperError('getShaderPrecision only has a stub for FRAGMENT_SHADER. Update it.');
+ }
+
+ if ((precisiontype !== WebGLConstants.HIGH_FLOAT) && (precisiontype !== WebGLConstants.HIGH_INT)) {
+ throw new DeveloperError('getShaderPrecision only has a stub for HIGH_FLOAT and HIGH_INT. Update it.');
+ }
+ //>>includeEnd('debug');
+
+ if (precisiontype === WebGLConstants.HIGH_FLOAT) {
+ return {
+ rangeMin : 127,
+ rangeMax : 127,
+ precision : 23
+ };
+ }
+
+ // HIGH_INT
+ return {
+ rangeMin : 31,
+ rangeMax : 30,
+ precision : 0
+ };
+ }
+
+ function readPixelsStub(x, y, width, height, format, type, pixels) {
+ return [0, 0, 0, 0];
+ }
+
+ return getWebGLStub;
+});
diff --git a/Specs/karma-main.js b/Specs/karma-main.js
index 9433609f61a7..69575ab18f1a 100644
--- a/Specs/karma-main.js
+++ b/Specs/karma-main.js
@@ -5,13 +5,15 @@
var included = '';
var excluded = '';
var webglValidation = false;
+ var webglStub = false;
var release = false;
if(__karma__.config.args){
included = __karma__.config.args[0];
excluded = __karma__.config.args[1];
webglValidation = __karma__.config.args[2];
- release = __karma__.config.args[3];
+ webglStub = __karma__.config.args[3];
+ release = __karma__.config.args[4];
}
var toRequire = ['Cesium'];
@@ -55,7 +57,7 @@
], function(
customizeJasmine) {
- customizeJasmine(jasmine.getEnv(), included, excluded, webglValidation, release);
+ customizeJasmine(jasmine.getEnv(), included, excluded, webglValidation, webglStub, release);
var specFiles = Object.keys(__karma__.files).filter(function(file) {
return /Spec\.js$/.test(file);
diff --git a/Specs/renderFragment.js b/Specs/renderFragment.js
deleted file mode 100644
index 94fbec8eac1a..000000000000
--- a/Specs/renderFragment.js
+++ /dev/null
@@ -1,73 +0,0 @@
-/*global define*/
-define([
- 'Core/defaultValue',
- 'Core/PrimitiveType',
- 'Renderer/Buffer',
- 'Renderer/BufferUsage',
- 'Renderer/ClearCommand',
- 'Renderer/DrawCommand',
- 'Renderer/RenderState',
- 'Renderer/ShaderProgram',
- 'Renderer/VertexArray'
- ], function(
- defaultValue,
- PrimitiveType,
- Buffer,
- BufferUsage,
- ClearCommand,
- DrawCommand,
- RenderState,
- ShaderProgram,
- VertexArray) {
- 'use strict';
-
- function renderFragment(context, fs, depth, clear) {
- var vs = 'attribute vec4 position; void main() { gl_PointSize = 1.0; gl_Position = position; }';
-
- var sp = ShaderProgram.fromCache({
- context : context,
- vertexShaderSource : vs,
- fragmentShaderSource : fs
- });
-
- depth = defaultValue(depth, 0.0);
- var va = new VertexArray({
- context : context,
- attributes : [{
- index : sp.vertexAttributes.position.index,
- vertexBuffer : Buffer.createVertexBuffer({
- context : context,
- typedArray : new Float32Array([0.0, 0.0, depth, 1.0]),
- usage : BufferUsage.STATIC_DRAW
- }),
- componentsPerAttribute : 4
- }]
- });
- var rs = RenderState.fromCache({
- depthTest : {
- enabled : true
- }
- });
-
- clear = defaultValue(clear, true);
- if (clear) {
- ClearCommand.ALL.execute(context);
- expect(context.readPixels()).toEqual([0, 0, 0, 0]);
- }
-
- var command = new DrawCommand({
- primitiveType : PrimitiveType.POINTS,
- shaderProgram : sp,
- vertexArray : va,
- renderState : rs
- });
- command.execute(context);
-
- sp = sp.destroy();
- va = va.destroy();
-
- return context.readPixels();
- }
-
- return renderFragment;
-});
diff --git a/Specs/spec-main.js b/Specs/spec-main.js
index f034b71aa49f..9ba3c174eeea 100644
--- a/Specs/spec-main.js
+++ b/Specs/spec-main.js
@@ -204,16 +204,20 @@
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
*/
- var queryString = Cesium.queryToObject(window.location.search.substring(1));
+ var queryString = Cesium.queryToObject(window.location.search.substring(1));
- if (queryString.webglValidation !== undefined) {
+ if (queryString.webglValidation !== undefined) {
window.webglValidation = true;
- }
+ }
+
+ if (queryString.webglStub !== undefined) {
+ window.webglStub = true;
+ }
- var queryStringForSpecFocus = Cesium.clone(queryString);
- if (queryStringForSpecFocus.category === 'none') {
+ var queryStringForSpecFocus = Cesium.clone(queryString);
+ if (queryStringForSpecFocus.category === 'none') {
delete queryStringForSpecFocus.category;
- }
+ }
var catchingExceptions = queryString['catch'];
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
diff --git a/gulpfile.js b/gulpfile.js
index 436aafaeeb11..1768879f9f9d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -627,6 +627,7 @@ gulp.task('test', function(done) {
var includeCategory = argv.include ? argv.include : '';
var excludeCategory = argv.exclude ? argv.exclude : '';
var webglValidation = argv.webglValidation ? argv.webglValidation : false;
+ var webglStub = argv.webglStub ? argv.webglStub : false;
var release = argv.release ? argv.release : false;
var failTaskOnError = argv.failTaskOnError ? argv.failTaskOnError : false;
var suppressPassed = argv.suppressPassed ? argv.suppressPassed : false;
@@ -660,7 +661,7 @@ gulp.task('test', function(done) {
},
files: files,
client: {
- args: [includeCategory, excludeCategory, webglValidation, release]
+ args: [includeCategory, excludeCategory, webglValidation, webglStub, release]
}
}, function(e) {
return done(failTaskOnError ? e : undefined);
diff --git a/index.html b/index.html
index afb65308d88c..f4e700456904 100644
--- a/index.html
+++ b/index.html
@@ -44,6 +44,7 @@