From f6bf4c44726fd3ea6b17f41c0ab0a317471e730b Mon Sep 17 00:00:00 2001 From: hates Date: Mon, 12 Jun 2017 23:31:04 +0300 Subject: [PATCH 1/7] Replaced DeveloperErrors with Check in Renderer folder --- Source/Renderer/Buffer.js | 6 +++--- Source/Renderer/Context.js | 6 +++--- Source/Renderer/CubeMap.js | 6 +++--- Source/Renderer/Framebuffer.js | 6 +++--- Source/Renderer/Renderbuffer.js | 14 +++++--------- Source/Renderer/Sampler.js | 6 +++--- Source/Renderer/Texture.js | 6 +++--- 7 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Source/Renderer/Buffer.js b/Source/Renderer/Buffer.js index edb489e7d313..64407c2d4581 100644 --- a/Source/Renderer/Buffer.js +++ b/Source/Renderer/Buffer.js @@ -7,6 +7,7 @@ define([ '../Core/DeveloperError', '../Core/IndexDatatype', '../Core/WebGLConstants', + '../Core/Check', './BufferUsage' ], function( defaultValue, @@ -16,6 +17,7 @@ define([ DeveloperError, IndexDatatype, WebGLConstants, + Check, BufferUsage) { 'use strict'; @@ -26,9 +28,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); if (!defined(options.typedArray) && !defined(options.sizeInBytes)) { throw new DeveloperError('Either options.sizeInBytes or options.typedArray is required.'); diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 7966c47e0418..b515ce239859 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -4,6 +4,7 @@ define([ '../Core/Color', '../Core/ComponentDatatype', '../Core/createGuid', + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -34,6 +35,7 @@ define([ Color, ComponentDatatype, createGuid, + Check, defaultValue, defined, defineProperties, @@ -179,9 +181,7 @@ define([ } //>>includeStart('debug', pragmas.debug); - if (!defined(canvas)) { - throw new DeveloperError('canvas is required.'); - } + Check.defined('canvas', canvas); //>>includeEnd('debug'); this._canvas = canvas; diff --git a/Source/Renderer/CubeMap.js b/Source/Renderer/CubeMap.js index 8f29baa1343b..7d78a6fdcdd8 100644 --- a/Source/Renderer/CubeMap.js +++ b/Source/Renderer/CubeMap.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -15,6 +16,7 @@ define([ './TextureMagnificationFilter', './TextureMinificationFilter' ], function( + Check, defaultValue, defined, defineProperties, @@ -36,9 +38,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); var context = options.context; diff --git a/Source/Renderer/Framebuffer.js b/Source/Renderer/Framebuffer.js index 2e2c1f97406a..6ce1d1427277 100644 --- a/Source/Renderer/Framebuffer.js +++ b/Source/Renderer/Framebuffer.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -8,6 +9,7 @@ define([ '../Core/PixelFormat', './ContextLimits' ], function( + Check, defaultValue, defined, defineProperties, @@ -72,9 +74,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); var gl = options.context._gl; diff --git a/Source/Renderer/Renderbuffer.js b/Source/Renderer/Renderbuffer.js index ebee4b0be504..9b60ea93a9f2 100644 --- a/Source/Renderer/Renderbuffer.js +++ b/Source/Renderer/Renderbuffer.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -8,6 +9,7 @@ define([ './ContextLimits', './RenderbufferFormat' ], function( + Check, defaultValue, defined, defineProperties, @@ -24,9 +26,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined(options.context); //>>includeEnd('debug'); var context = options.context; @@ -42,17 +42,13 @@ define([ throw new DeveloperError('Invalid format.'); } - if (width <= 0) { - throw new DeveloperError('Width must be greater than zero.'); - } + Check.typeOf.number.greaterThan('width', width, 0); if (width > maximumRenderbufferSize) { throw new DeveloperError('Width must be less than or equal to the maximum renderbuffer size (' + maximumRenderbufferSize + '). Check maximumRenderbufferSize.'); } - if (height <= 0) { - throw new DeveloperError('Height must be greater than zero.'); - } + Check.typeOf.number.greaterThan('height', height, 0); if (height > maximumRenderbufferSize) { throw new DeveloperError('Height must be less than or equal to the maximum renderbuffer size (' + maximumRenderbufferSize + '). Check maximumRenderbufferSize.'); diff --git a/Source/Renderer/Sampler.js b/Source/Renderer/Sampler.js index 85c8c6e32bcb..fe422a639eb4 100644 --- a/Source/Renderer/Sampler.js +++ b/Source/Renderer/Sampler.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -8,6 +9,7 @@ define([ './TextureMinificationFilter', './TextureWrap' ], function( + Check, defaultValue, defined, defineProperties, @@ -46,9 +48,7 @@ define([ throw new DeveloperError('Invalid sampler.magnificationFilter.'); } - if (maximumAnisotropy < 1.0) { - throw new DeveloperError('sampler.maximumAnisotropy must be greater than or equal to one.'); - } + Check.typeOf.number.greaterThanOrEquals('maximumAnisotropy', maximumAnisotropy, 1.0); //>>includeEnd('debug'); this._wrapS = wrapS; diff --git a/Source/Renderer/Texture.js b/Source/Renderer/Texture.js index a330e3aecfc0..fd51f44b01f3 100644 --- a/Source/Renderer/Texture.js +++ b/Source/Renderer/Texture.js @@ -1,6 +1,7 @@ /*global define*/ define([ '../Core/Cartesian2', + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -17,6 +18,7 @@ define([ './TextureMinificationFilter' ], function( Cartesian2, + Check, defaultValue, defined, defineProperties, @@ -37,9 +39,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); var context = options.context; From 08a2d73792a8ab79268ecd0130046520d5c14edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ATE=C5=9E?= Date: Tue, 13 Jun 2017 17:37:56 +0300 Subject: [PATCH 2/7] tweak --- Source/Renderer/Renderbuffer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Renderer/Renderbuffer.js b/Source/Renderer/Renderbuffer.js index 9b60ea93a9f2..dd45d3f2c35c 100644 --- a/Source/Renderer/Renderbuffer.js +++ b/Source/Renderer/Renderbuffer.js @@ -26,7 +26,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - Check.defined(options.context); + Check.defined('options.context', options.context); //>>includeEnd('debug'); var context = options.context; From f44054fb778c8e10f5c73376e3e1547e3be59df7 Mon Sep 17 00:00:00 2001 From: hates Date: Fri, 16 Jun 2017 00:50:04 +0300 Subject: [PATCH 3/7] Replaced DeveloperErrors with Check in Renderer --- Source/Renderer/Buffer.js | 21 ++++------ Source/Renderer/ComputeEngine.js | 10 ++--- Source/Renderer/Context.js | 53 ++++++-------------------- Source/Renderer/CubeMapFace.js | 30 +++++---------- Source/Renderer/ShaderProgram.js | 10 ++--- Source/Renderer/Texture.js | 57 +++++++++------------------- Source/Renderer/VertexArray.js | 19 +++------- Source/Renderer/VertexArrayFacade.js | 6 +-- Source/Renderer/loadCubeMap.js | 6 +-- 9 files changed, 66 insertions(+), 146 deletions(-) diff --git a/Source/Renderer/Buffer.js b/Source/Renderer/Buffer.js index 64407c2d4581..9b9585470388 100644 --- a/Source/Renderer/Buffer.js +++ b/Source/Renderer/Buffer.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -7,9 +8,9 @@ define([ '../Core/DeveloperError', '../Core/IndexDatatype', '../Core/WebGLConstants', - '../Core/Check', './BufferUsage' ], function( + Check, defaultValue, defined, defineProperties, @@ -17,7 +18,6 @@ define([ DeveloperError, IndexDatatype, WebGLConstants, - Check, BufferUsage) { 'use strict'; @@ -59,9 +59,7 @@ define([ } //>>includeStart('debug', pragmas.debug); - if (sizeInBytes <= 0) { - throw new DeveloperError('Buffer size must be greater than zero.'); - } + Check.typeOf.number.greaterThan('sizeInBytes', sizeInBytes, 0); //>>includeEnd('debug'); var buffer = gl.createBuffer(); @@ -119,9 +117,7 @@ define([ */ Buffer.createVertexBuffer = function(options) { //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); return new Buffer({ @@ -180,9 +176,7 @@ define([ */ Buffer.createIndexBuffer = function(options) { //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); if (!IndexDatatype.validate(options.indexDatatype)) { throw new DeveloperError('Invalid indexDatatype.'); @@ -250,9 +244,8 @@ define([ offsetInBytes = defaultValue(offsetInBytes, 0); //>>includeStart('debug', pragmas.debug); - if (!arrayView) { - throw new DeveloperError('arrayView is required.'); - } + Check.defined('arrayView', arrayView); + if (offsetInBytes + arrayView.byteLength > this._sizeInBytes) { throw new DeveloperError('This buffer is not large enough.'); } diff --git a/Source/Renderer/ComputeEngine.js b/Source/Renderer/ComputeEngine.js index 13235334a893..3b05fcacf034 100644 --- a/Source/Renderer/ComputeEngine.js +++ b/Source/Renderer/ComputeEngine.js @@ -1,6 +1,7 @@ /*global define*/ define([ '../Core/BoundingRectangle', + '../Core/Check', '../Core/Color', '../Core/defined', '../Core/destroyObject', @@ -14,6 +15,7 @@ define([ './ShaderProgram' ], function( BoundingRectangle, + Check, Color, defined, destroyObject, @@ -76,9 +78,7 @@ define([ ComputeEngine.prototype.execute = function(computeCommand) { //>>includeStart('debug', pragmas.debug); - if (!defined(computeCommand)) { - throw new DeveloperError('computeCommand is required.'); - } + Check.defined('computeCommand', computeCommand); //>>includeEnd('debug'); // This may modify the command's resources, so do error checking afterwards @@ -91,9 +91,7 @@ define([ throw new DeveloperError('computeCommand.fragmentShaderSource or computeCommand.shaderProgram is required.'); } - if (!defined(computeCommand.outputTexture)) { - throw new DeveloperError('computeCommand.outputTexture is required.'); - } + Check.defined('computeCommand.outputTexture', computeCommand.outputTexture); //>>includeEnd('debug'); var outputTexture = computeCommand.outputTexture; diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index b515ce239859..ee31f290a298 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -1,10 +1,10 @@ /*global define*/ define([ + '../Core/Check', '../Core/clone', '../Core/Color', '../Core/ComponentDatatype', '../Core/createGuid', - '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -31,11 +31,11 @@ define([ './UniformState', './VertexArray' ], function( + Check, clone, Color, ComponentDatatype, createGuid, - Check, defaultValue, defined, defineProperties, @@ -892,25 +892,10 @@ define([ throw new DeveloperError('drawCommand.primitiveType is required and must be valid.'); } - if (!defined(va)) { - throw new DeveloperError('drawCommand.vertexArray is required.'); - } - - if (offset < 0) { - throw new DeveloperError('drawCommand.offset must be greater than or equal to zero.'); - } - - if (count < 0) { - throw new DeveloperError('drawCommand.count must be greater than or equal to zero.'); - } - - if (instanceCount < 0) { - throw new DeveloperError('drawCommand.instanceCount must be greater than or equal to zero.'); - } - - if (instanceCount > 0 && !context.instancedArrays) { - throw new DeveloperError('Instanced arrays extension is not supported'); - } + Check.defined('drawCommand.vertexArray', va); + Check.typeOf.numgreaterThanOrEquals('drawCommand.offset', offset, 0); + Check.typeOf.numgreaterThanOrEquals('drawCommand.count', count, 0); + Check.typeOf.numgreaterThanOrEquals('drawCommand.instanceCount', instanceCount, 0); //>>includeEnd('debug'); context._us.model = defaultValue(drawCommand._modelMatrix, Matrix4.IDENTITY); @@ -941,13 +926,8 @@ define([ Context.prototype.draw = function(drawCommand, passState) { //>>includeStart('debug', pragmas.debug); - if (!defined(drawCommand)) { - throw new DeveloperError('drawCommand is required.'); - } - - if (!defined(drawCommand._shaderProgram)) { - throw new DeveloperError('drawCommand.shaderProgram is required.'); - } + Check.defined('drawCommand', drawCommand); + Check.defined('drawCommand.shaderProgram', drawCommand._shaderProgram); //>>includeEnd('debug'); passState = defaultValue(passState, this._defaultPassState); @@ -991,13 +971,8 @@ define([ var framebuffer = readState.framebuffer; //>>includeStart('debug', pragmas.debug); - if (width <= 0) { - throw new DeveloperError('readState.width must be greater than zero.'); - } - - if (height <= 0) { - throw new DeveloperError('readState.height must be greater than zero.'); - } + Check.typeOf.number.greaterThan('readState.width', width, 0); + Check.typeOf.number.greaterThan('readState.height', height, 0); //>>includeEnd('debug'); var pixels = new Uint8Array(4 * width * height); @@ -1098,9 +1073,7 @@ define([ */ Context.prototype.getObjectByPickColor = function(pickColor) { //>>includeStart('debug', pragmas.debug); - if (!defined(pickColor)) { - throw new DeveloperError('pickColor is required.'); - } + Check.defined('pickColor', pickColor); //>>includeEnd('debug'); return this._pickObjects[pickColor.toRgba()]; @@ -1149,9 +1122,7 @@ define([ */ Context.prototype.createPickId = function(object) { //>>includeStart('debug', pragmas.debug); - if (!defined(object)) { - throw new DeveloperError('object is required.'); - } + Check.defined('object', object); //>>includeEnd('debug'); // the increment and assignment have to be separate statements to diff --git a/Source/Renderer/CubeMapFace.js b/Source/Renderer/CubeMapFace.js index ca923da99fe7..2b81ffced48c 100644 --- a/Source/Renderer/CubeMapFace.js +++ b/Source/Renderer/CubeMapFace.js @@ -1,10 +1,12 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defineProperties', '../Core/DeveloperError', './PixelDatatype' ], function( + Check, defaultValue, defineProperties, DeveloperError, @@ -75,15 +77,9 @@ define([ yOffset = defaultValue(yOffset, 0); //>>includeStart('debug', pragmas.debug); - if (!source) { - throw new DeveloperError('source is required.'); - } - if (xOffset < 0) { - throw new DeveloperError('xOffset must be greater than or equal to zero.'); - } - if (yOffset < 0) { - throw new DeveloperError('yOffset must be greater than or equal to zero.'); - } + Check.defined('source', source); + Check.typeOf.number.greaterThanOrEquals('xOffset', xOffset, 0); + Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); if (xOffset + source.width > this._size) { throw new DeveloperError('xOffset + source.width must be less than or equal to width.'); } @@ -143,18 +139,10 @@ define([ height = defaultValue(height, this._size); //>>includeStart('debug', pragmas.debug); - if (xOffset < 0) { - throw new DeveloperError('xOffset must be greater than or equal to zero.'); - } - if (yOffset < 0) { - throw new DeveloperError('yOffset must be greater than or equal to zero.'); - } - if (framebufferXOffset < 0) { - throw new DeveloperError('framebufferXOffset must be greater than or equal to zero.'); - } - if (framebufferYOffset < 0) { - throw new DeveloperError('framebufferYOffset must be greater than or equal to zero.'); - } + Check.typeOf.number.greaterThanOrEquals('xOffset', xOffset, 0); + Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); + Check.typeOf.number.greaterThanOrEquals('framebufferXOffset', framebufferXOffset, 0); + Check.typeOf.number.greaterThanOrEquals('framebufferYOffset', framebufferYOffset, 0); if (xOffset + width > this._size) { throw new DeveloperError('xOffset + source.width must be less than or equal to width.'); } diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index a76faa6acb8e..f7e1463231d1 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/defaultValue', '../Core/defined', '../Core/defineProperties', @@ -11,6 +12,7 @@ define([ './createUniform', './createUniformArray' ], function( + Check, defaultValue, defined, defineProperties, @@ -66,9 +68,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('context', context); //>>includeEnd('debug'); return options.context.shaderCache.getShaderProgram(options); @@ -78,9 +78,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('context', context); //>>includeEnd('debug'); return options.context.shaderCache.replaceShaderProgram(options); diff --git a/Source/Renderer/Texture.js b/Source/Renderer/Texture.js index fd51f44b01f3..38b160e1801a 100644 --- a/Source/Renderer/Texture.js +++ b/Source/Renderer/Texture.js @@ -79,17 +79,13 @@ define([ throw new DeveloperError('options requires a source field to create an initialized texture or width and height fields to create a blank texture.'); } - if (width <= 0) { - throw new DeveloperError('Width must be greater than zero.'); - } + Check.typeOf.number.greaterThan('width', width, 0); if (width > ContextLimits.maximumTextureSize) { throw new DeveloperError('Width must be less than or equal to the maximum texture size (' + ContextLimits.maximumTextureSize + '). Check maximumTextureSize.'); } - if (height <= 0) { - throw new DeveloperError('Height must be greater than zero.'); - } + Check.typeOf.number.greaterThan('height', height, 0); if (height > ContextLimits.maximumTextureSize) { throw new DeveloperError('Height must be less than or equal to the maximum texture size (' + ContextLimits.maximumTextureSize + '). Check maximumTextureSize.'); @@ -251,9 +247,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); var context = options.context; @@ -267,21 +261,16 @@ define([ var framebuffer = options.framebuffer; //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('context is required.'); - } if (!PixelFormat.validate(pixelFormat)) { throw new DeveloperError('Invalid pixelFormat.'); } if (PixelFormat.isDepthFormat(pixelFormat) || PixelFormat.isCompressedFormat(pixelFormat)) { throw new DeveloperError('pixelFormat cannot be DEPTH_COMPONENT, DEPTH_STENCIL or a compressed format.'); } - if (framebufferXOffset < 0) { - throw new DeveloperError('framebufferXOffset must be greater than or equal to zero.'); - } - if (framebufferYOffset < 0) { - throw new DeveloperError('framebufferYOffset must be greater than or equal to zero.'); - } + + Check.typeOf.number.greaterThanOrEquals('framebufferXOffset', framebufferXOffset, 0); + Check.typeOf.number.greaterThanOrEquals('framebufferYOffset', framebufferYOffset, 0); + if (framebufferXOffset + width > gl.drawingBufferWidth) { throw new DeveloperError('framebufferXOffset + width must be less than or equal to drawingBufferWidth'); } @@ -433,21 +422,17 @@ define([ yOffset = defaultValue(yOffset, 0); //>>includeStart('debug', pragmas.debug); - if (!defined(source)) { - throw new DeveloperError('source is required.'); - } + Check.defined('source', source); if (PixelFormat.isDepthFormat(this._pixelFormat)) { throw new DeveloperError('Cannot call copyFrom when the texture pixel format is DEPTH_COMPONENT or DEPTH_STENCIL.'); } if (PixelFormat.isCompressedFormat(this._pixelFormat)) { throw new DeveloperError('Cannot call copyFrom with a compressed texture pixel format.'); } - if (xOffset < 0) { - throw new DeveloperError('xOffset must be greater than or equal to zero.'); - } - if (yOffset < 0) { - throw new DeveloperError('yOffset must be greater than or equal to zero.'); - } + + Check.typeOf.number.greaterThanOrEquals('xOffset', xOffset, 0); + Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); + if (xOffset + source.width > this._width) { throw new DeveloperError('xOffset + source.width must be less than or equal to width.'); } @@ -511,18 +496,12 @@ define([ if (PixelFormat.isCompressedFormat(this._pixelFormat)) { throw new DeveloperError('Cannot call copyFrom with a compressed texture pixel format.'); } - if (xOffset < 0) { - throw new DeveloperError('xOffset must be greater than or equal to zero.'); - } - if (yOffset < 0) { - throw new DeveloperError('yOffset must be greater than or equal to zero.'); - } - if (framebufferXOffset < 0) { - throw new DeveloperError('framebufferXOffset must be greater than or equal to zero.'); - } - if (framebufferYOffset < 0) { - throw new DeveloperError('framebufferYOffset must be greater than or equal to zero.'); - } + + Check.typeOf.number.greaterThanOrEquals('xOffset', xOffset, 0); + Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); + Check.typeOf.number.greaterThanOrEquals('framebufferXOffset', framebufferXOffset, 0); + Check.typeOf.number.greaterThanOrEquals('framebufferYOffset', framebufferYOffset, 0); + if (xOffset + width > this._width) { throw new DeveloperError('xOffset + width must be less than or equal to width.'); } diff --git a/Source/Renderer/VertexArray.js b/Source/Renderer/VertexArray.js index a02d27dc7996..fe0d78592d32 100644 --- a/Source/Renderer/VertexArray.js +++ b/Source/Renderer/VertexArray.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/ComponentDatatype', '../Core/defaultValue', '../Core/defined', @@ -14,6 +15,7 @@ define([ './BufferUsage', './ContextLimits' ], function( + Check, ComponentDatatype, defaultValue, defined, @@ -267,13 +269,8 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } - - if (!defined(options.attributes)) { - throw new DeveloperError('options.attributes is required.'); - } + Check.defined('options.context', options.context); + Check.defined('options.attributes', options.attributes); //>>includeEnd('debug'); var context = options.context; @@ -529,9 +526,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - if (!defined(options.context)) { - throw new DeveloperError('options.context is required.'); - } + Check.defined('options.context', options.context); //>>includeEnd('debug'); var context = options.context; @@ -670,9 +665,7 @@ define([ */ VertexArray.prototype.getAttribute = function(index) { //>>includeStart('debug', pragmas.debug); - if (!defined(index)) { - throw new DeveloperError('index is required.'); - } + Check.defined('index', index); //>>includeEnd('debug'); return this._attributes[index]; diff --git a/Source/Renderer/VertexArrayFacade.js b/Source/Renderer/VertexArrayFacade.js index d7a793888394..9655d813d03b 100644 --- a/Source/Renderer/VertexArrayFacade.js +++ b/Source/Renderer/VertexArrayFacade.js @@ -1,5 +1,6 @@ /*global define*/ define([ + '../Core/Check', '../Core/ComponentDatatype', '../Core/defaultValue', '../Core/defined', @@ -10,6 +11,7 @@ define([ './BufferUsage', './VertexArray' ], function( + Check, ComponentDatatype, defaultValue, defined, @@ -26,9 +28,7 @@ define([ */ function VertexArrayFacade(context, attributes, sizeInVertices, instanced) { //>>includeStart('debug', pragmas.debug); - if (!context) { - throw new DeveloperError('context is required.'); - } + Check.defined('context', context); if (!attributes || (attributes.length === 0)) { throw new DeveloperError('At least one attribute is required.'); } diff --git a/Source/Renderer/loadCubeMap.js b/Source/Renderer/loadCubeMap.js index 81d6528aff59..a49c7f47f725 100644 --- a/Source/Renderer/loadCubeMap.js +++ b/Source/Renderer/loadCubeMap.js @@ -1,11 +1,13 @@ /*global define*/ define([ + '../Core/Check', '../Core/defined', '../Core/DeveloperError', '../Core/loadImage', '../ThirdParty/when', './CubeMap' ], function( + Check, defined, DeveloperError, loadImage, @@ -51,9 +53,7 @@ define([ */ function loadCubeMap(context, urls, allowCrossOrigin) { //>>includeStart('debug', pragmas.debug); - if (!defined(context)) { - throw new DeveloperError('context is required.'); - } + Check.defined('context', context); if ((!defined(urls)) || (!defined(urls.positiveX)) || (!defined(urls.negativeX)) || From 3f5afd1442d3c45a642ebf1a7ab1157b69ae9d86 Mon Sep 17 00:00:00 2001 From: hates Date: Fri, 16 Jun 2017 00:52:29 +0300 Subject: [PATCH 4/7] tweak --- Source/Renderer/ShaderProgram.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/ShaderProgram.js b/Source/Renderer/ShaderProgram.js index f7e1463231d1..c3f11cabaae4 100644 --- a/Source/Renderer/ShaderProgram.js +++ b/Source/Renderer/ShaderProgram.js @@ -68,7 +68,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - Check.defined('context', context); + Check.defined('options.context', options.context); //>>includeEnd('debug'); return options.context.shaderCache.getShaderProgram(options); @@ -78,7 +78,7 @@ define([ options = defaultValue(options, defaultValue.EMPTY_OBJECT); //>>includeStart('debug', pragmas.debug); - Check.defined('context', context); + Check.defined('options.context', options.context); //>>includeEnd('debug'); return options.context.shaderCache.replaceShaderProgram(options); From e0079f2433dc347c30ccc626bfce15c47cf5d5e6 Mon Sep 17 00:00:00 2001 From: hates Date: Fri, 16 Jun 2017 01:00:13 +0300 Subject: [PATCH 5/7] typo --- Source/Renderer/Context.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index ee31f290a298..6a6d5b81d6bc 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -893,9 +893,9 @@ define([ } Check.defined('drawCommand.vertexArray', va); - Check.typeOf.numgreaterThanOrEquals('drawCommand.offset', offset, 0); - Check.typeOf.numgreaterThanOrEquals('drawCommand.count', count, 0); - Check.typeOf.numgreaterThanOrEquals('drawCommand.instanceCount', instanceCount, 0); + Check.typeOf.number.greaterThanOrEquals('drawCommand.offset', offset, 0); + Check.typeOf.number.greaterThanOrEquals('drawCommand.count', count, 0); + Check.typeOf.number.greaterThanOrEquals('drawCommand.instanceCount', instanceCount, 0); //>>includeEnd('debug'); context._us.model = defaultValue(drawCommand._modelMatrix, Matrix4.IDENTITY); From cf9583bba67d215fa0ef71da49a4a27481752f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ATE=C5=9E?= Date: Thu, 22 Jun 2017 11:35:30 +0300 Subject: [PATCH 6/7] tweak --- Source/Renderer/Buffer.js | 4 +++- Source/Renderer/Context.js | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/Buffer.js b/Source/Renderer/Buffer.js index 9b9585470388..57ca4f9bf923 100644 --- a/Source/Renderer/Buffer.js +++ b/Source/Renderer/Buffer.js @@ -59,7 +59,9 @@ define([ } //>>includeStart('debug', pragmas.debug); - Check.typeOf.number.greaterThan('sizeInBytes', sizeInBytes, 0); + if (sizeInBytes <= 0) { + throw new DeveloperError('Buffer size must be greater than zero.'); + } //>>includeEnd('debug'); var buffer = gl.createBuffer(); diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 6a6d5b81d6bc..cacb97ae4444 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -894,7 +894,9 @@ define([ Check.defined('drawCommand.vertexArray', va); Check.typeOf.number.greaterThanOrEquals('drawCommand.offset', offset, 0); - Check.typeOf.number.greaterThanOrEquals('drawCommand.count', count, 0); + if (defined(count)) { + Check.typeOf.number.greaterThanOrEquals('drawCommand.count', count, 0); + } Check.typeOf.number.greaterThanOrEquals('drawCommand.instanceCount', instanceCount, 0); //>>includeEnd('debug'); From 53ec1527178c45fdedf47f5173a2222a9d239a42 Mon Sep 17 00:00:00 2001 From: hpinkos Date: Fri, 20 Oct 2017 15:35:05 -0400 Subject: [PATCH 7/7] cleanup --- Source/Renderer/Buffer.js | 16 +- Source/Renderer/Context.js | 248 +++++++++++++++++------------- Source/Renderer/Texture.js | 22 +-- Specs/Renderer/VertexArraySpec.js | 2 +- 4 files changed, 152 insertions(+), 136 deletions(-) diff --git a/Source/Renderer/Buffer.js b/Source/Renderer/Buffer.js index 95122f003e21..48d5ae49f1ba 100644 --- a/Source/Renderer/Buffer.js +++ b/Source/Renderer/Buffer.js @@ -37,8 +37,9 @@ define([ throw new DeveloperError('Cannot pass in both options.sizeInBytes and options.typedArray.'); } - if (defined(options.typedArray) && !(typeof options.typedArray === 'object' && typeof options.typedArray.byteLength === 'number')) { - throw new DeveloperError('options.typedArray must be a typed array'); + if (defined(options.typedArray)) { + Check.typeOf.object('options.typedArray', options.typedArray); + Check.typeOf.number('options.typedArray.byteLength', options.typedArray.byteLength); } if (!BufferUsage.validate(options.usage)) { @@ -58,9 +59,7 @@ define([ } //>>includeStart('debug', pragmas.debug); - if (sizeInBytes <= 0) { - throw new DeveloperError('Buffer size must be greater than zero.'); - } + Check.typeOf.number.greaterThan('sizeInBytes', sizeInBytes, 0); //>>includeEnd('debug'); var buffer = gl.createBuffer(); @@ -183,7 +182,7 @@ define([ throw new DeveloperError('Invalid indexDatatype.'); } - if ((options.indexDatatype === IndexDatatype.UNSIGNED_INT) && !options.context.elementIndexUint) { + if (options.indexDatatype === IndexDatatype.UNSIGNED_INT && !options.context.elementIndexUint) { throw new DeveloperError('IndexDatatype.UNSIGNED_INT requires OES_element_index_uint, which is not supported on this system. Check context.elementIndexUint.'); } //>>includeEnd('debug'); @@ -246,10 +245,7 @@ define([ //>>includeStart('debug', pragmas.debug); Check.defined('arrayView', arrayView); - - if (offsetInBytes + arrayView.byteLength > this._sizeInBytes) { - throw new DeveloperError('This buffer is not large enough.'); - } + Check.typeOf.number.lessThanOrEquals('offsetInBytes + arrayView.byteLength', offsetInBytes + arrayView.byteLength, this._sizeInBytes); //>>includeEnd('debug'); var gl = this._gl; diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index 508a91f465d5..e74b5866408b 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -1,89 +1,90 @@ define([ - '../Core/Check', - '../Core/clone', - '../Core/Color', - '../Core/ComponentDatatype', - '../Core/createGuid', - '../Core/defaultValue', - '../Core/defined', - '../Core/defineProperties', - '../Core/destroyObject', - '../Core/DeveloperError', - '../Core/Geometry', - '../Core/GeometryAttribute', - '../Core/Matrix4', - '../Core/PrimitiveType', - '../Core/RuntimeError', - '../Core/WebGLConstants', - '../Shaders/ViewportQuadVS', - './BufferUsage', - './ClearCommand', - './ContextLimits', - './CubeMap', - './DrawCommand', - './PassState', - './PickFramebuffer', - './RenderState', - './ShaderCache', - './ShaderProgram', - './Texture', - './UniformState', - './VertexArray' - ], function( - Check, - clone, - Color, - ComponentDatatype, - createGuid, - defaultValue, - defined, - defineProperties, - destroyObject, - DeveloperError, - Geometry, - GeometryAttribute, - Matrix4, - PrimitiveType, - RuntimeError, - WebGLConstants, - ViewportQuadVS, - BufferUsage, - ClearCommand, - ContextLimits, - CubeMap, - DrawCommand, - PassState, - PickFramebuffer, - RenderState, - ShaderCache, - ShaderProgram, - Texture, - UniformState, - VertexArray) { + '../Core/Check', + '../Core/clone', + '../Core/Color', + '../Core/ComponentDatatype', + '../Core/createGuid', + '../Core/defaultValue', + '../Core/defined', + '../Core/defineProperties', + '../Core/destroyObject', + '../Core/DeveloperError', + '../Core/Geometry', + '../Core/GeometryAttribute', + '../Core/Matrix4', + '../Core/PrimitiveType', + '../Core/RuntimeError', + '../Core/WebGLConstants', + '../Shaders/ViewportQuadVS', + './BufferUsage', + './ClearCommand', + './ContextLimits', + './CubeMap', + './DrawCommand', + './PassState', + './PickFramebuffer', + './RenderState', + './ShaderCache', + './ShaderProgram', + './Texture', + './UniformState', + './VertexArray' +], function( + Check, + clone, + Color, + ComponentDatatype, + createGuid, + defaultValue, + defined, + defineProperties, + destroyObject, + DeveloperError, + Geometry, + GeometryAttribute, + Matrix4, + PrimitiveType, + RuntimeError, + WebGLConstants, + ViewportQuadVS, + BufferUsage, + ClearCommand, + ContextLimits, + CubeMap, + DrawCommand, + PassState, + PickFramebuffer, + RenderState, + ShaderCache, + ShaderProgram, + Texture, + UniformState, + VertexArray) { 'use strict'; /*global WebGLRenderingContext*/ + /*global WebGL2RenderingContext*/ function errorToString(gl, error) { var message = 'WebGL Error: '; switch (error) { - case gl.INVALID_ENUM: - message += 'INVALID_ENUM'; - break; - case gl.INVALID_VALUE: - message += 'INVALID_VALUE'; - break; - case gl.INVALID_OPERATION: - message += 'INVALID_OPERATION'; - break; - case gl.OUT_OF_MEMORY: - message += 'OUT_OF_MEMORY'; - break; - case gl.CONTEXT_LOST_WEBGL: - message += 'CONTEXT_LOST_WEBGL lost'; - break; - default: - message += 'Unknown (' + error + ')'; + case gl.INVALID_ENUM: + message += 'INVALID_ENUM'; + break; + case gl.INVALID_VALUE: + message += 'INVALID_VALUE'; + break; + case gl.INVALID_OPERATION: + message += 'INVALID_OPERATION'; + break; + case gl.OUT_OF_MEMORY: + message += 'OUT_OF_MEMORY'; + break; + case gl.CONTEXT_LOST_WEBGL: + message += 'CONTEXT_LOST_WEBGL lost'; + break; + default: + message += 'Unknown (' + error + ')'; } return message; @@ -92,7 +93,7 @@ define([ function createErrorMessage(gl, glFunc, glFuncArguments, error) { var message = errorToString(gl, error) + ': ' + glFunc.name + '('; - for ( var i = 0; i < glFuncArguments.length; ++i) { + for (var i = 0; i < glFuncArguments.length; ++i) { if (i !== 0) { message += ', '; } @@ -303,33 +304,61 @@ define([ if (webgl2) { var that = this; - glCreateVertexArray = function () { return that._gl.createVertexArray(); }; - glBindVertexArray = function(vao) { that._gl.bindVertexArray(vao); }; - glDeleteVertexArray = function(vao) { that._gl.deleteVertexArray(vao); }; + glCreateVertexArray = function() { + return that._gl.createVertexArray(); + }; + glBindVertexArray = function(vao) { + that._gl.bindVertexArray(vao); + }; + glDeleteVertexArray = function(vao) { + that._gl.deleteVertexArray(vao); + }; - glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { gl.drawElementsInstanced(mode, count, type, offset, instanceCount); }; - glDrawArraysInstanced = function(mode, first, count, instanceCount) { gl.drawArraysInstanced(mode, first, count, instanceCount); }; - glVertexAttribDivisor = function(index, divisor) { gl.vertexAttribDivisor(index, divisor); }; + glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { + gl.drawElementsInstanced(mode, count, type, offset, instanceCount); + }; + glDrawArraysInstanced = function(mode, first, count, instanceCount) { + gl.drawArraysInstanced(mode, first, count, instanceCount); + }; + glVertexAttribDivisor = function(index, divisor) { + gl.vertexAttribDivisor(index, divisor); + }; - glDrawBuffers = function(buffers) { gl.drawBuffers(buffers); }; + glDrawBuffers = function(buffers) { + gl.drawBuffers(buffers); + }; } else { vertexArrayObject = getExtension(gl, ['OES_vertex_array_object']); if (defined(vertexArrayObject)) { - glCreateVertexArray = function() { return vertexArrayObject.createVertexArrayOES(); }; - glBindVertexArray = function(vertexArray) { vertexArrayObject.bindVertexArrayOES(vertexArray); }; - glDeleteVertexArray = function(vertexArray) { vertexArrayObject.deleteVertexArrayOES(vertexArray); }; + glCreateVertexArray = function() { + return vertexArrayObject.createVertexArrayOES(); + }; + glBindVertexArray = function(vertexArray) { + vertexArrayObject.bindVertexArrayOES(vertexArray); + }; + glDeleteVertexArray = function(vertexArray) { + vertexArrayObject.deleteVertexArrayOES(vertexArray); + }; } instancedArrays = getExtension(gl, ['ANGLE_instanced_arrays']); if (defined(instancedArrays)) { - glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { instancedArrays.drawElementsInstancedANGLE(mode, count, type, offset, instanceCount); }; - glDrawArraysInstanced = function(mode, first, count, instanceCount) { instancedArrays.drawArraysInstancedANGLE(mode, first, count, instanceCount); }; - glVertexAttribDivisor = function(index, divisor) { instancedArrays.vertexAttribDivisorANGLE(index, divisor); }; + glDrawElementsInstanced = function(mode, count, type, offset, instanceCount) { + instancedArrays.drawElementsInstancedANGLE(mode, count, type, offset, instanceCount); + }; + glDrawArraysInstanced = function(mode, first, count, instanceCount) { + instancedArrays.drawArraysInstancedANGLE(mode, first, count, instanceCount); + }; + glVertexAttribDivisor = function(index, divisor) { + instancedArrays.vertexAttribDivisorANGLE(index, divisor); + }; } drawBuffers = getExtension(gl, ['WEBGL_draw_buffers']); if (defined(drawBuffers)) { - glDrawBuffers = function(buffers) { drawBuffers.drawBuffersWEBGL(buffers); }; + glDrawBuffers = function(buffers) { + drawBuffers.drawBuffersWEBGL(buffers); + }; } } @@ -787,18 +816,18 @@ define([ var message; switch (status) { - case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - message = 'Framebuffer is not complete. Incomplete attachment: at least one attachment point with a renderbuffer or texture attached has its attached object no longer in existence or has an attached image with a width or height of zero, or the color attachment point has a non-color-renderable image attached, or the depth attachment point has a non-depth-renderable image attached, or the stencil attachment point has a non-stencil-renderable image attached. Color-renderable formats include GL_RGBA4, GL_RGB5_A1, and GL_RGB565. GL_DEPTH_COMPONENT16 is the only depth-renderable format. GL_STENCIL_INDEX8 is the only stencil-renderable format.'; - break; - case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: - message = 'Framebuffer is not complete. Incomplete dimensions: not all attached images have the same width and height.'; - break; - case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - message = 'Framebuffer is not complete. Missing attachment: no images are attached to the framebuffer.'; - break; - case gl.FRAMEBUFFER_UNSUPPORTED: - message = 'Framebuffer is not complete. Unsupported: the combination of internal formats of the attached images violates an implementation-dependent set of restrictions.'; - break; + case gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + message = 'Framebuffer is not complete. Incomplete attachment: at least one attachment point with a renderbuffer or texture attached has its attached object no longer in existence or has an attached image with a width or height of zero, or the color attachment point has a non-color-renderable image attached, or the depth attachment point has a non-depth-renderable image attached, or the stencil attachment point has a non-stencil-renderable image attached. Color-renderable formats include GL_RGBA4, GL_RGB5_A1, and GL_RGB565. GL_DEPTH_COMPONENT16 is the only depth-renderable format. GL_STENCIL_INDEX8 is the only stencil-renderable format.'; + break; + case gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: + message = 'Framebuffer is not complete. Incomplete dimensions: not all attached images have the same width and height.'; + break; + case gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + message = 'Framebuffer is not complete. Missing attachment: no images are attached to the framebuffer.'; + break; + case gl.FRAMEBUFFER_UNSUPPORTED: + message = 'Framebuffer is not complete. Unsupported: the combination of internal formats of the attached images violates an implementation-dependent set of restrictions.'; + break; } throw new DeveloperError(message); @@ -928,6 +957,9 @@ define([ Check.typeOf.number.greaterThanOrEquals('drawCommand.count', count, 0); } Check.typeOf.number.greaterThanOrEquals('drawCommand.instanceCount', instanceCount, 0); + if (instanceCount > 0 && !context.instancedArrays) { + throw new DeveloperError('Instanced arrays extension is not supported'); + } //>>includeEnd('debug'); context._us.model = defaultValue(drawCommand._modelMatrix, Matrix4.IDENTITY); @@ -1032,10 +1064,10 @@ define([ componentDatatype : ComponentDatatype.FLOAT, componentsPerAttribute : 2, values : [ - -1.0, -1.0, + -1.0, -1.0, 1.0, -1.0, - 1.0, 1.0, - -1.0, 1.0 + 1.0, 1.0, + -1.0, 1.0 ] }), diff --git a/Source/Renderer/Texture.js b/Source/Renderer/Texture.js index 36eafde43c54..19d5decc9bb7 100644 --- a/Source/Renderer/Texture.js +++ b/Source/Renderer/Texture.js @@ -283,10 +283,9 @@ define([ if (PixelFormat.isDepthFormat(pixelFormat) || PixelFormat.isCompressedFormat(pixelFormat)) { throw new DeveloperError('pixelFormat cannot be DEPTH_COMPONENT, DEPTH_STENCIL or a compressed format.'); } - + Check.defined('options.context', options.context); Check.typeOf.number.greaterThanOrEquals('framebufferXOffset', framebufferXOffset, 0); Check.typeOf.number.greaterThanOrEquals('framebufferYOffset', framebufferYOffset, 0); - if (framebufferXOffset + width > gl.drawingBufferWidth) { throw new DeveloperError('framebufferXOffset + width must be less than or equal to drawingBufferWidth'); } @@ -445,16 +444,10 @@ define([ if (PixelFormat.isCompressedFormat(this._pixelFormat)) { throw new DeveloperError('Cannot call copyFrom with a compressed texture pixel format.'); } - Check.typeOf.number.greaterThanOrEquals('xOffset', xOffset, 0); Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); - - if (xOffset + source.width > this._width) { - throw new DeveloperError('xOffset + source.width must be less than or equal to width.'); - } - if (yOffset + source.height > this._height) { - throw new DeveloperError('yOffset + source.height must be less than or equal to height.'); - } + Check.typeOf.number.lessThanOrEquals('xOffset + source.width', xOffset + source.width, this._width); + Check.typeOf.number.lessThanOrEquals('yOffset + source.height', yOffset + source.height, this._height); //>>includeEnd('debug'); var gl = this._context._gl; @@ -517,13 +510,8 @@ define([ Check.typeOf.number.greaterThanOrEquals('yOffset', yOffset, 0); Check.typeOf.number.greaterThanOrEquals('framebufferXOffset', framebufferXOffset, 0); Check.typeOf.number.greaterThanOrEquals('framebufferYOffset', framebufferYOffset, 0); - - if (xOffset + width > this._width) { - throw new DeveloperError('xOffset + width must be less than or equal to width.'); - } - if (yOffset + height > this._height) { - throw new DeveloperError('yOffset + height must be less than or equal to height.'); - } + Check.typeOf.number.lessThanOrEquals('xOffset + width', xOffset + width, this._width); + Check.typeOf.number.lessThanOrEquals('yOffset + height', yOffset + height, this._height); //>>includeEnd('debug'); var gl = this._context._gl; diff --git a/Specs/Renderer/VertexArraySpec.js b/Specs/Renderer/VertexArraySpec.js index f59af9fb5fa6..1974532d9ddf 100644 --- a/Specs/Renderer/VertexArraySpec.js +++ b/Specs/Renderer/VertexArraySpec.js @@ -510,7 +510,7 @@ defineSuite([ attributes : [{ vertexBuffer : Buffer.createVertexBuffer({ context : context, - sizeInBytes : new Float32Array([0, 0, 0, 1]), + sizeInBytes : new Float32Array([0, 0, 0, 1]).byteLength, usage : BufferUsage.STATIC_DRAW }), componentsPerAttribute : 4