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

Using conrod to render GUI one frame at a time #840

Closed
Boscop opened this issue Oct 12, 2016 · 2 comments
Closed

Using conrod to render GUI one frame at a time #840

Boscop opened this issue Oct 12, 2016 · 2 comments

Comments

@Boscop
Copy link
Contributor

Boscop commented Oct 12, 2016

I'm using conrod for the GUI in a VST plugin, but I'm having some problems with event handling:
The way the GUI is run in a VST is, one frame at a time.
So I can't use while let Some(event) = gui.window.next() { because that stalls, but when I try to do one frame by doing if let Some(event) = gui.window.next() { it doesn't register input events. So I tried while let Some(event) = gui.window.poll_event() { which seemed like a logical way to do it (only process events that are in the queue right now, don't block to wait for new events at the end of the queue), then I get input events, but no render events so the GUI doesn't render!
So what should I do to handle the GUI one frame at a time / without internal event loop?

Also, I have another question: What exactly does the event loop do behind the scenes (with the value given by window.set_ups())? Is there a way to turn the event loop off?

(This question is also relevant for writing game UIs, where the game should be in control of the loop and the GUI should be drawn over the scene.)

@mitchmindtree
Copy link
Contributor

The way the GUI is run in a VST is, one frame at a time

By this, do you mean the VST's Host indicates when it's ready to draw the VST's frame so that it can synchronise the drawing with it's own rendering loop?

If so, I think you're on the right track with using poll_event, however you might need to create the Render events for conrod yourself, as I'm guessing they are being triggered by the VST's host rather than piston_window (I could be wrong). You can create Render events for conrod manually using this function (the dpi field is the "dots per inch" multiplier for the display, e.g. on regular displays this is 1.0, on retina displays it is 2.0). You'll want to create one of these events and call ui.handle_event(render_event); each time the VST requires rendering a frame.

I'm not sure I can provide much more help without seeing some code though. How does the VST request a frame at a time? Some kind of callback function? Does it provide you a GL context upon which you need to draw?

Also, I have another question: What exactly does the event loop do behind the scenes (with the value given by window.set_ups())? Is there a way to turn the event loop off?

These are better questions for the piston_window or piston repos (this might be related to what you're after?).

@Boscop
Copy link
Contributor Author

Boscop commented Oct 12, 2016

Thanks, I created an issue here that also gives more detail:
PistonDevelopers/piston_window#167

@Boscop Boscop closed this as completed Oct 12, 2016
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