diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-12-24 13:53:16 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2019-12-24 13:53:16 +0100 |
commit | 3c51a1994f41b625823c4f15e92396b5498ce23c (patch) | |
tree | 7a96310ec32df82ac87039ea555300bcab510a5e /src/renderer/view/util | |
parent | 33926af829848050c54c698ed22da9fe2b912aea (diff) | |
download | rpgedit-3c51a1994f41b625823c4f15e92396b5498ce23c.tar rpgedit-3c51a1994f41b625823c4f15e92396b5498ce23c.zip |
Move renderer into "runtime" subdirectory
Diffstat (limited to 'src/renderer/view/util')
-rw-r--r-- | src/renderer/view/util/image.ts | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/renderer/view/util/image.ts b/src/renderer/view/util/image.ts deleted file mode 100644 index 37c5e7f..0000000 --- a/src/renderer/view/util/image.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Renderer } from '../renderer/renderer'; - -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]; -} |