flambe
flambe copied to clipboard
Change System.init to return a promise to cope with asynchronous platform initialization
FlashPlatform's initialization is actually asynchronous, in that we must wait for Stage3DRenderer to acquire a Context3D before we're ready to roll. Since the Flash platform requires a Context3D before textures can be loaded, quickly loading textures after calling System.init was causing undesirable behavior (null textures), due to a Context3D not yet being available. With this change, we can wait for a platform to become ready before continuing with other work.
Hi, thanks for the patch! What I usually do is to wait for System.renderer.hasGPU to become true, but this seems better.
Another possible idea, what if calling System.init() was unnecessary? We should be able to do some magic to invoke the main method only when the platform is ready.
I vote for magic :star2:
We should be able to do some magic to invoke the main method only when the platform is ready.
Personally, I'm very new to Haxe so I'm not so up on the magical possibilities, but off the top of my head I'd say:
Alter the build process to feed the Haxe compiler a -main flag that points to a Flambe class that just calls System.init(), waits for the platform to become ready, and then calls out to the user's main class specified in flambe.yaml.