Skip to content

Instantly share code, notes, and snippets.

@neiltron
Last active September 6, 2017 13:22
Show Gist options
  • Save neiltron/5f3bb1f1e4b8bbcb85c5fb09c1ad1e84 to your computer and use it in GitHub Desktop.
Save neiltron/5f3bb1f1e4b8bbcb85c5fb09c1ad1e84 to your computer and use it in GitHub Desktop.
Example of texture setup that doesn't work on iOS
let regl = new Regl({
canvas: canvas,
extensions: ['OES_texture_float', 'OES_texture_half_float'],
optionalExtensions: ['oes_texture_float_linear', 'OES_texture_half_float']
});
const RADIUS = dimensions.width > 800 ? 256 : 64;
const TEXTURE_DATA = (Array(RADIUS * RADIUS * 4)).fill(1).map((p, i) => {
angle = i / (RADIUS / 2);
if (i % 4 == 0) {
return Math.sin(angle);
} else if (i % 4 == 1) {
return Math.cos(angle);
} else if (i % 4 == 2) {
return angle / 10;
} else {
return 0;
}
});
const state = new Array(2).fill(0).map(() => regl.framebuffer({
depthStencil: false,
colorFormat: 'rgba',
color: regl.texture({
data: TEXTURE_DATA,
radius: RADIUS,
type: dimensions.width > 800 ? 'float' : 'half float'
})
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment