summaryrefslogtreecommitdiffstats
path: root/src/view/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/view/util')
-rw-r--r--src/view/util/image.ts14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/view/util/image.ts b/src/view/util/image.ts
index 7baeccc..4c5e386 100644
--- a/src/view/util/image.ts
+++ b/src/view/util/image.ts
@@ -16,18 +16,17 @@ export function mkTexture(
src: HTMLCanvasElement|HTMLImageElement,
frame: number = 0,
total: number = 1,
-): [WebGLTexture, [number, number], SpriteCoords] {
+): [WebGLTexture, SpriteCoords] {
const gl = r.getContext();
const texture = gl.createTexture();
if (!texture)
throw new Error('unable to create texture');
const w = src.width, h = src.height / total;
- const w2 = nextPowerOf2(w), h2 = nextPowerOf2(h);
const canvas = document.createElement('canvas');
- canvas.width = w2;
- canvas.height = h2;
+ canvas.width = w;
+ canvas.height = h;
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D;
ctx.drawImage(src, 0, frame * h, w, h, 0, 0, w, h);
@@ -39,12 +38,9 @@ export function mkTexture(
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
- const size: [number, number] = [
- w / r.coordScale, h / r.coordScale,
- ];
const coords: SpriteCoords = [
- 0, 0, w2 / r.coordScale, h2 / r.coordScale,
+ 0, 0, w / r.coordScale, h / r.coordScale,
];
- return [texture, size, coords];
+ return [texture, coords];
}