-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Is any way to hack emscripten_set_main_loop() and return back into main() after quiting of a loop? #6227
Comments
This is impossible in asm.js and in wasm without a system like emterpreter or asyncify.
C++ lambda functions can act as callbacks, and can safely access private data. |
To use Empterpreter or Asyncify I need to correctly refere functions are has sleeps and loops, but to make that easier I need use extern "C", or try to guess it from object files generated by the compiler, etc.
I meant that I need to refer a function which a class member or friend independent C++ function in the EMPTERPRITY_WHITELIST to compile everything except of those functions to don't cause a lag of entire game. I have tried to refer some of functions, but result won't work correct... |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant. |
About "Asyncify", I have missed that up... I have checked it out more and looks that what I needed, I need to check this in action... I should be able to run this: int exec()
{
struct State xxx;
int running = 0, ret = 0;
while(running)
{
doAnything1(xxx)
doAnything2(xxx)
...
renderEverything(xxx)
waitSome(&ret);
if(xxx.quit)
running = 0;
}
return ret;
} and I don't want to be forced use this: static struct State xxx;
void runStep()
{
doAnything1(xxx)
doAnything2(xxx)
...
renderEverything(xxx)
} As in my engine, there are many cases of sub-loops are will cause stuck of the entire engine, for example, spawned message boxes are will run own loop inside self and will render parent scene's content and self above. |
I think Asyncify is the way to go if you want to keep you stack while yielding to the event loop. Can you verify and close this issue if that works for you? |
Yes, I'll close this issue once I'll solve my problem. P.S. Thanks that bot who reminded me about this question, I forgot about this unsolved task, so, it's a time to finally solve it! 😁 |
Okay, right now I can't test the build because I have met this error #9317 , will re-try tomorrow... |
Have found just now that #9317 is looking like has been fixed! 🦊 😄 |
Hello! Today I finally did a test, and I did some own side works to fix up my project to work with Emscripten WohlSoft/Moondust-Project@3c5acff |
As I see, using of emscripten_set_main_loop() I have no way to return back into main() function to change scene into another and start emscripten_set_main_loop() again, but on another function/class.
I thinking how to hack this as Emterpreter even looks good, but result works VERY slow and I have no idea how to correctly selectively interpret loop calls are in most of cases are members of scene classes (or I getting an error of linking, or result doesn't works properly).
I thinking about a way to hack emscripten_set_main_loop() and return back to main, as idea I have:
Then, in any next time, repeat same operation when beginning a process of a next scene.
Are you think it is possible to solve this?
P.S. As my game engine has sub-loops (as example, a message or other dialog box requested from a middle of code that does own control listening and a render of parent scene's state), I would think is to use Emterpreter or even disable support of child-boxes for Emscripten builds until I'll find a proper way to selectively interpret class-membered loop calls. I can't just use a regular function callbacks as there are must be friends and there are can't be "extern 'C'" without loss of private access.
The text was updated successfully, but these errors were encountered: