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

Rendering without having the main loop owned by magnum #6

Closed
kekeblom opened this issue Oct 18, 2019 · 5 comments
Closed

Rendering without having the main loop owned by magnum #6

kekeblom opened this issue Oct 18, 2019 · 5 comments
Milestone

Comments

@kekeblom
Copy link

Is it possible to have the main loop owned by the python application?

What I would like to do is something like this:

app = Application()
while True: 
  app.mainLoopIteration()
  # do other stuff

Now this could be achieved by just exposing the mainLoopIteration method on Sdl2Application. However, then the python application would have to check for the exit flag and the flags are not exposed outside the application class.

Is there a way to do this that I'm overlooking or would this have to be implemented? If this would have to be implemented, what do you feel would be the appropriate way to change the api to support such a use case?

@mosra mosra added this to the 2019.0b milestone Oct 18, 2019
@mosra
Copy link
Owner

mosra commented Oct 18, 2019

Hi!

One idea would be:

while app.exit_requested:
    app.main_loop_iteration()

    # other stuff

But the exit_requested would be absolutely useless in other use cases, not a fan. Then I thought I could turn exit() into a property, so you could do stuff like

while not app.exit:
    app.main_loop_iteration()

    ...

    if thing: app.exit = 0 # Exit with a success return code

... but that feels to me like not being very intuitive / looking weird, and not following the C++ API at all. Then, what about having main_loop_iteration return a bool, saying False if the app is meant to exit? That could work well and fix the same issue on the C++ side too I think:

while app.main_loop_iteration():
    # other stuff

Thoughts? :)

@kekeblom
Copy link
Author

I feel the last one is probably the cleanest solution and this would support the use case nicely.

@mosra
Copy link
Owner

mosra commented Oct 18, 2019

Yeah, that's my feeling too :) I'll do the changes and let you know once they hit master on both the main magnum repo and this one.

The mainLoopIteration() is currently only on Sdl2Application, not on GlfwApplication. Is that okay?

@mosra mosra mentioned this issue Oct 18, 2019
60 tasks
@mosra
Copy link
Owner

mosra commented Oct 20, 2019

With mosra/magnum@82f5386 and 7068412 this is now in master :)

@mosra mosra closed this as completed Oct 20, 2019
@kekeblom
Copy link
Author

Wow that was fast. Was actually planning to take a stab at this myself today.

Thanks a lot for the help!

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

No branches or pull requests

2 participants