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

Create a virtual ofBaseMainLoop to allow custom loop implementations #5470

Open
chuckleplant opened this issue Mar 3, 2017 · 4 comments
Open

Comments

@chuckleplant
Copy link
Contributor

Based on forum thread

Now that the main loop is nicely isolated to an external class it seems useful to allow users to extend or change the functionality.

I'll give it a shot and PR later

Must be done before #3489
Related #5122

@arturoc
Copy link
Member

arturoc commented Mar 3, 2017

just to clear up what i said in the forum, the idea would be to have a new base class, ofBaseMainLoop, have ofMainLoop extend that and ofSetMainLoop accept an ofBaseMainLoop instead of an ofMainLoop.

People wanting to create their own loops can extend ofBaseMainLoop

@chuckleplant
Copy link
Contributor Author

The fact that ofMainLoop::addWindow is templated makes it a bit hard to make ofBaseMainLoop an empty interface. May need to move the templated method to the base class....not sure about it. Why is it templated? I see two places where it's used.

ofMainLoop::addWindow
ofSetupOpenGL

Why don't they receive ofAppBaseWindow instead?

@arturoc
Copy link
Member

arturoc commented Mar 5, 2017

didn't remembered about that, that method is templated so it can call some methods on the class itself rather than the instance which wouldn't work with dynamic dispatching. there's some ways to do this but it's more complicated than i though, ofSetMainLoop would probably need to be templated so it can accept any mainloop class but not 100% sure on the details, i'll take a look when i have a moment

@chuckleplant
Copy link
Contributor Author

So far I've just moved the templated method to the base. Changes here.

So far it works but the base interface looks a bit ugly.

so it can call some methods on the class itself rather than the instance which wouldn't work with dynamic dispatching

Not sure what you mean. Maybe it can be fixed forcing ofAppBaseWindow (or ofAppBaseGLWindow) inheritance instead of the templated Window?

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

No branches or pull requests

2 participants