diff --git a/API.md b/API.md index edb933d6..f4220556 100644 --- a/API.md +++ b/API.md @@ -1696,7 +1696,7 @@ A data source from an image can be one of the following types: | `data` | Input data (see below) | | | `mipmap` | See below for a description | `false` | | `flipY` | Flips textures vertically when uploading | `false` | -| `alignment` | Sets unpack alignment per pixel | `1` | +| `alignment` | Sets unpack alignment per row | `1` | | `premultiplyAlpha` | Premultiply alpha when unpacking | `false` | | `colorSpace` | Sets colorspace conversion | `'none'` | | `data` | Image data for the texture | `null` | diff --git a/README.md b/README.md index 6a1d2b3e..cc8231c6 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ To define a command you specify a mixture of static and dynamic data for the object. Once this is done, `regl` takes this description and then compiles it into optimized JavaScript code. For example, here is a simple `regl` program to draw a triangle: -```JavaScript +```js // Calling the regl module with no arguments creates a full screen canvas and // WebGL context, and then uses this context to initialize a new REGL instance const regl = require('regl')() diff --git a/lib/util/check.js b/lib/util/check.js index b79fed39..d7298d77 100644 --- a/lib/util/check.js +++ b/lib/util/check.js @@ -530,8 +530,10 @@ function checkTexture2D (info, mipData, limits) { if (img.compressed) { // TODO: check size for compressed images } else if (img.data) { - check(img.data.byteLength === mw * mh * - Math.max(pixelSize(img.type, c), img.unpackAlignment), + // check(img.data.byteLength === mw * mh * + // Math.max(pixelSize(img.type, c), img.unpackAlignment), + var rowSize = Math.ceil(pixelSize(img.type, c) * mw / img.unpackAlignment) * img.unpackAlignment + check(img.data.byteLength === rowSize * mh, 'invalid data for image, buffer size is inconsistent with image format') } else if (img.element) { // TODO: check element can be loaded diff --git a/test/texture2d.js b/test/texture2d.js index 184a561a..0541594f 100644 --- a/test/texture2d.js +++ b/test/texture2d.js @@ -515,9 +515,9 @@ tape('texture 2d', function (t) { regl.texture({ shape: [2, 2, 1], flipY: true, - alignment: 2, + alignment: 4, colorSpace: 'none', - data: new Uint8Array([1, 0, 2, 0, 3, 0, 4, 0]) + data: new Uint8Array([1, 2, 0, 0, 3, 4, 0, 0]) }), { width: 2, @@ -535,7 +535,7 @@ tape('texture 2d', function (t) { regl.texture({ shape: [4, 4, 1], flipY: true, - alignment: 2, + alignment: 4, mipmap: [ { alignment: 1, @@ -549,7 +549,7 @@ tape('texture 2d', function (t) { { flipY: false, colorSpace: 'none', - data: new Uint8Array([1, 0, 2, 0, 3, 0, 4, 0]) + data: new Uint8Array([1, 2, 0, 0, 3, 4, 0, 0]) }, { alignment: 1,