nannou icon indicating copy to clipboard operation
nannou copied to clipboard

Create a "headless" example (an example that demonstrates an application with no windows)

Open mitchmindtree opened this issue 6 years ago • 6 comments

We shouldn't make the assumption that the user always wants one or more windows - there are plenty of applications where the user might only want to use audio, lasers, etc.

This will involve tweaking some internals, and perhaps separating all of the windowing logic and user input event loop from the App type. I've been meaning to do a refactor of the App type so it could be useful to consider this issue while doing so.

mitchmindtree avatar Nov 04 '18 04:11 mitchmindtree

It would be nice if nannou could still provide raw keyboard and mouse events in a "headless" context, as these might be useful for interacting with alternative displays like LED arrays, laser projectors, etc. This would require creating a winit::EventLoop instance, but without actually building any windows. I know that some backends support raw device events (device events unassociated with particular windows) but I haven't tested each of them to know for sure. Perhaps the EventLoop can be lazily initialized only if one of these input functions are requested? In the case that no input function is requested, we can assume the EventLoop is not needed.

I imagine the API would still be quite similar - the model function would still be necessary for setup and Model initialisation, and would allow for spawning these alternate outputs etc.

The vulkan instance should still be available in case the user wishes to do some form of image processing or GPU compute.

mitchmindtree avatar Jul 27 '19 14:07 mitchmindtree

Hello, any news on this issue? :)

From my reading of the docs and a couple brief attempts, it would seem that nannou doesn't yet support headless Apps...

tmladek avatar Nov 18 '20 16:11 tmladek

Hey @tmladek, that's correct, we're still in the same state. My previous comment mentions some ideas on how we might be able to make some progress here if anyone is interested in contributing. Otherwise I'm sure we'll get around to this at some point, it just hasn't had high enough priority for us to focus on this just yet.

Another idea - Before trying to work on a solution in nannou itself, I think I would first try to land a headless.rs example in winit (the library nannou uses to manage windowing and input device events) that demonstrates a program that continues to receive device input (e.g. mouse and keyboard), but does not need a window to do so. Once that can be shown to work nicely in a cross platform manner, it should be trivial to land headless support in nannou.

mitchmindtree avatar Dec 04 '20 17:12 mitchmindtree

To add another potential use case: I'm currently looking for a general way to render video without displaying it in real time so rendering an one hour video doesn't take one hour.

bitzl avatar Sep 12 '22 22:09 bitzl

@bitzl Shouldn't that be possible already? You'd advance by one frame for each of your video, capture it (see #187), and then stitch it together into a video file

merlindru avatar Sep 29 '23 08:09 merlindru

@merlindru This still requires a window or I missed a point in the link?

melMass avatar Dec 29 '23 09:12 melMass