| 1 | /** Helpers for dynamic canvas → Framework image textures (e.g. HP bars). */ |
| 2 | |
| 3 | export function frameworkImageFromCanvas (canvas) |
| 4 | { |
| 5 | const fw = new image(canvas, 1, 1, false); |
| 6 | fw.cacheWidth = -1; |
| 7 | fw.cacheHeight = -1; |
| 8 | return fw; |
| 9 | } |
| 10 | |
| 11 | export function invalidateCanvasTexture (scene, canvas) |
| 12 | { |
| 13 | const glContext = scene?.glContext; |
| 14 | if (!glContext?.textures || !canvas) |
| 15 | { return; } |
| 16 | const texture = glContext.textures.get(canvas); |
| 17 | if (!texture) |
| 18 | { return; } |
| 19 | glContext.gl.deleteTexture(texture); |
| 20 | glContext.textures.delete(canvas); |
| 21 | } |