Skip to content

Commit 8ca52fc

Browse files
authored
Merge pull request #255 from Strilanc/dev
Dev
2 parents 8c29eba + 11c719a commit 8ca52fc

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/browser/Polyfills.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,24 @@ Float32Array.prototype.slice = Float32Array.prototype.slice || function(a, b) {
55
Float64Array.prototype.slice = Float64Array.prototype.slice || function(a, b) {
66
return new Float64Array(Array.from(this).slice(a, b));
77
};
8-
Uint32Array.prototype.slice = Float64Array.prototype.slice || function(a, b) {
8+
Uint32Array.prototype.slice = Uint32Array.prototype.slice || function(a, b) {
99
return new Uint32Array(Array.from(this).slice(a, b));
1010
};
11-
Uint16Array.prototype.slice = Float64Array.prototype.slice || function(a, b) {
11+
Int32Array.prototype.slice = Int32Array.prototype.slice || function(a, b) {
12+
return new Int32Array(Array.from(this).slice(a, b));
13+
};
14+
Uint16Array.prototype.slice = Uint16Array.prototype.slice || function(a, b) {
1215
return new Uint16Array(Array.from(this).slice(a, b));
1316
};
14-
Uint8Array.prototype.slice = Float64Array.prototype.slice || function(a, b) {
17+
Int16Array.prototype.slice = Int16Array.prototype.slice || function(a, b) {
18+
return new Int16Array(Array.from(this).slice(a, b));
19+
};
20+
Uint8Array.prototype.slice = Uint8Array.prototype.slice || function(a, b) {
1521
return new Uint8Array(Array.from(this).slice(a, b));
1622
};
23+
Int8Array.prototype.slice = Int8Array.prototype.slice || function(a, b) {
24+
return new Int8Array(Array.from(this).slice(a, b));
25+
};
1726

1827
const ARRAY_ITER = function() {
1928
let self = this;
@@ -28,6 +37,9 @@ Float64Array.prototype[Symbol.iterator] = Float64Array.prototype[Symbol.iterator
2837
Uint32Array.prototype[Symbol.iterator] = Uint32Array.prototype[Symbol.iterator] || ARRAY_ITER;
2938
Uint16Array.prototype[Symbol.iterator] = Uint16Array.prototype[Symbol.iterator] || ARRAY_ITER;
3039
Uint8Array.prototype[Symbol.iterator] = Uint8Array.prototype[Symbol.iterator] || ARRAY_ITER;
40+
Int32Array.prototype[Symbol.iterator] = Int32Array.prototype[Symbol.iterator] || ARRAY_ITER;
41+
Int16Array.prototype[Symbol.iterator] = Int16Array.prototype[Symbol.iterator] || ARRAY_ITER;
42+
Int8Array.prototype[Symbol.iterator] = Int8Array.prototype[Symbol.iterator] || ARRAY_ITER;
3143

3244
// This was missing on the iPhone I tested.
3345
window.performance = window.performance || {};

src/webgl/ShaderCoders.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,6 @@ function changeShaderCoder(newCoder) {
710710
function _tryWriteAndReadFloatingPointTexture() {
711711
let texture = new WglTexture(1, 1, WebGLRenderingContext.FLOAT);
712712
let shader = new WglShader(`void main() { gl_FragColor = vec4(2.0, 3.5, 7.0, -7654321.0); }`);
713-
//noinspection UnusedCatchParameterJS
714713
try {
715714
shader.withArgs().renderTo(texture);
716715
let result = texture.readPixels(false);
@@ -736,12 +735,11 @@ function _tryWriteAndPassFloatingPointWithByteReadTexture() {
736735
let passer = new WglShader(`uniform sampler2D t; void main() {
737736
vec4 v = texture2D(t, gl_FragCoord.xy);
738737
if (v == vec4(2.0, 3.0, 5.0, -7654321.0)) { // Testing that expected precision is present.
739-
gl_FragColor = vec4(1.1, 3.0, 5.0, 7.0) / 255.0;
738+
gl_FragColor = vec4(2.0, 3.0, 5.0, 254.0) / 255.0;
740739
} else {
741740
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
742741
}
743742
}`);
744-
//noinspection UnusedCatchParameterJS
745743
try {
746744
shader.withArgs().renderTo(textureFloat);
747745
passer.withArgs(WglArg.texture('t', textureFloat)).renderTo(textureByte);
@@ -751,7 +749,7 @@ function _tryWriteAndPassFloatingPointWithByteReadTexture() {
751749
result[0] === 2 &&
752750
result[1] === 3 &&
753751
result[2] === 5 &&
754-
result[3] === 7;
752+
result[3] === 254;
755753
} catch (ex) {
756754
console.warn(ex);
757755
return false;

0 commit comments

Comments
 (0)