diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-12-08 12:39:18 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2018-12-08 12:39:18 +0100 |
commit | b3950330e3351437f153c6c1debb3821d6e28864 (patch) | |
tree | 0b381b523045bd59cd679825a11976a45813fc24 /src/view/util | |
parent | 439dcf391784ea3abb61473c74b9c27fcd9fdc2d (diff) | |
download | rpgedit-b3950330e3351437f153c6c1debb3821d6e28864.tar rpgedit-b3950330e3351437f153c6c1debb3821d6e28864.zip |
Create Electron app
Diffstat (limited to 'src/view/util')
-rw-r--r-- | src/view/util/image.ts | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/view/util/image.ts b/src/view/util/image.ts deleted file mode 100644 index 0ad5d16..0000000 --- a/src/view/util/image.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { Renderer } from '../renderer/renderer'; -import { SpriteCoords } from '../sprite'; - -export function loadImage(url: string): Promise<HTMLImageElement> { - return new Promise((resolve, reject) => { - const img = new Image(); - img.addEventListener('load', () => { resolve(img); }); - img.addEventListener('error', () => { reject(new Error('failed to load ' + url)); }); - img.src = url; - }); -} - -export function mkTexture( - r: Renderer, - src: HTMLCanvasElement|HTMLImageElement, -): [WebGLTexture, [number, number]] { - const gl = r.getContext(); - const texture = gl.createTexture(); - if (!texture) - throw new Error('unable to create texture'); - - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, src); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); - 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] = [ - src.width / r.coordScale, src.height / r.coordScale, - ]; - - return [texture, size]; -} |