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
Doing
surface.buffer = buffer.create(surface.width * surface.height, { {name=hash("rgba"), type=buffer.VALUE_TYPE_UINT8, count=4} } )
surface.stream = buffer.get_stream(surface.buffer, hash("rgba"))
resource.set_texture(surface.resource_path,surface.header,surface.buffer)
Also gives inconsistent results desktop vs HTML5. Desktop clears the resource texture, HTML5 doesn’t and does some weird stuff.
Is there a better way? I think maybe having two buffers and copy the blank buffer onto the primary buffer might solve memory issue on HTML5?
Here’s the project it’s for if anyone wants to tinker
Getting clear to work and be fast is crucial for this project to be viable.