From 5bc5319543e46dded33a02db621d6a33568b0a34 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Thu, 27 Jun 2019 11:57:26 -0700 Subject: [PATCH] WASM Texture Caching * Refactor texture caching in render.Engine: * New interface method: NewTexture(filename string, image.Image) * WASM immediately encodes the image to PNG and generates a JavaScript `Image()` object to load it with a data URI and keep it in memory. * SDL2 saves the bitmap to disk as it did before. * WASM: deprecate the sessionStorage for holding image data. Session storage methods panic if called. The image data is directly kept in Go memory as a js.Value holding an Image(). * Shared Memory workaround: the level.Chunk.ToBitmap() function is where chunk textures get cached, but it had no access to the render.Engine used in the game. The `pkg/shmem` package holds global pointers to common structures like the CurrentRenderEngine as a work-around. * Also shmem.Flash() so Doodle can make its d.Flash() function globally available, any sub-package can now flash text to the screen regardless of source code location. * JavaScript API for Doodads now has a global Flash() function available. * WASM: Handle window resize so Doodle can recompute its dimensions instead of scaling/shrinking the view. --- dev-assets/doodads/azulian/azulian.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-assets/doodads/azulian/azulian.js b/dev-assets/doodads/azulian/azulian.js index 5178cc7..8636700 100644 --- a/dev-assets/doodads/azulian/azulian.js +++ b/dev-assets/doodads/azulian/azulian.js @@ -1,5 +1,5 @@ function main() { - log.Info("Azulian '%s' initialized!", Self.Doodad.Title); + Flash("Azulian '%s' initialized!", Self.Doodad.Title); var playerSpeed = 12; var gravity = 4;