Looping through the buffer and setting to a clear color to each value is too slow.
If I try to remake the buffer every frame it crashes on HTML5 build
Uncaught abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 268435456, (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ") at Error
Copying a blank buffer seems to work for HTML5 build. Have to manually clear the buffers for HTML5 build though on start as it doesn’t clear them properly when used with resources like desktop does.
The more pixels modified a frame the slower it is no matter what. How can that be made faster? As long as not too much is drawn it’s fast but the more being modified it gets very slow.
Well, setting each pixel one by one via Lua is never going to be fast. Each call from Lua to C has an overhead cost. If you want it as fast as possible, you’ll have to do it inside the native extension. Essentially, you want to set as many pixels at once in once call E.g. a clear function, or a copy function.
I’d guess that a single Lua to C call with a bufferstream batch would be faster than dozens of calls for drawing individual shapes so I’ll test making a bufferstream batch native extension with cls and batching of streams all at once. If that’s still too slow there are other ideas I can test.