Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change System.init to return a promise to cope with asynchronous platform initialization #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

purplepwny
Copy link
Contributor

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.

… initialization that may be asynchronous.

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, due a Context3D not yet being available. With this change, we can wait for a platform to become ready before continuing with other work.
@aduros
Copy link
Owner

aduros commented Jul 7, 2014

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.

@markknol
Copy link
Contributor

markknol commented Jul 8, 2014

I vote for magic 🌟

@purplepwny
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants