tidy up on shutdown to allow multiple `init`/`shutdown` cycles per process
- Hide window.
- Clear
contextStack. - Reset cached
lazyproperties. Had to convert from namespace to struct to allow default initialisation reset. - Set
state::initialized = false.
thanks for this, it would be great to cleanly shutdown & reinitialize (some sloppy engineering on my part that I have put off fixing for many years)
I'm afraid of some subtle bugs due to static variables. I have been gradually removing/consolidating static variables wherever possible, but there are still some hanging around. Also, openGL resource management & shutdown.
After enabling tests, it looks like there's a huge amount of memory being leaked. I think maybe the render::engine is not being freed, and is getting recreated each time? It will take some more debugging; I started looking at this but ran out of time for now.
Thanks for the feedback. I can't believe ASAN only checks memory leaks on GCC. That's really strange.
Anyway, I've updated ownership of the engine. render::engine is now a std::unique_ptr<Engine>. All other references to the concrete engine, private to the backend, are essentially weak raw pointers.
This looks to be superceeded by #311