Dynamic mesh support
MartinSStewart opened this issue · 5 comments
Hi, I'm interested in rendering circuit boards similar to this
https://3c1703fe8d.site.internapcdn.net/newman/gfx/news/hires/2009/runningelect.jpg
Ideally I'd generate one large mesh for the entire circuit board. The layout of the circuit board isn't known at compile time though and as I understand it, all meshes need to be known at compile time, as generating them in the view causes a memory leak.
It seems like currently the best I can do then is have a rectangle and circle mesh at compile time and use a bunch of them to render the entire circuit board.
As a test to see if it would be feasible to do this I ran a quick benchmark by drawing the same circle mesh with varying transformation matrices. Around 600 circles per frame was the limit before the frame rate would start to drop. This seems too low to achieve what I'm aiming for.
So if possible, it would be great to support creating new meshes after compile time.
Edit: I realized that meshes can still be created during runtime so long as they are stored in the model and not modified. This works well enough for my purposes though it would still be nice to have some way to free/modify existing meshes.
Hi @MartinSStewart I just opened a PR #9 that should free the meshes if they are not referenced anymore.
I don't think we can easily allow modifications, because Elm is a pure language.
Thanks, fixing the memory leak is the most important part for me.
The change is in master, hopefully will be published in a few days.
@MartinSStewart according to https://stackoverflow.com/questions/31250052/are-webgltextures-garbage-collected this is not fully fixed. This approach should be fine for occasional changes but not for constantly creating new meshes/textures every frame which is something that you probably shouldn't be doing anyway.
Ah, that's a shame. Still, being able to create new meshes occasionally is useful.