FLTK use with Raspberry Pi OS

45 views
Skip to first unread message

Dave Branson

unread,
Nov 4, 2020, 2:07:46 PM11/4/20
to fltk.general
I have a small C++ app that uses several FLTK features and currently runs well from the command line - I want to run it at boot-up using rc.local for auto start, but I don't know if the desktop GUI is required to be running for FLTK-based apps to operate.  Can one run a FLTK app without having first launched the GUI?

imm

unread,
Nov 4, 2020, 2:14:08 PM11/4/20
to general fltk
On Wed, 4 Nov 2020, 19:07 Dave Branson wrote:
I have a small C++ app that uses several FLTK features and currently runs well from the command line - I want to run it at boot-up using rc.local for auto start, but I don't know if the desktop GUI is required to be running for FLTK-based apps to operate.  Can one run a FLTK app without having first launched the GUI?


It depends what you are doing, really.

Under X11, with fltk, so long as you do not do anything that opens the display, the application can run without X.

The classic example of this is the "fluid -c" operation, where fluid runs but does not open its display, so can be run even with no GUI context.

Is that what you are asking?
Or do you mean something else?
-- 
Ian
From my Fairphone FP3

Dave Branson

unread,
Nov 4, 2020, 2:25:02 PM11/4/20
to fltk.general
I am opening a window, displaying a logo and launching a slider for input.  Thanks.

Greg Ercolano

unread,
Nov 4, 2020, 2:30:11 PM11/4/20
to fltkg...@googlegroups.com
On 2020-11-04 11:04, Dave Branson wrote:
> I have a small C++ app that uses several FLTK features and currently runs well from the command line - I want to run it at boot-up using rc.local for auto start, but I don't know if the desktop GUI is required to be running for FLTK-based apps to operate.  Can one run a FLTK app without having first launched the GUI?

    You need X running for FLTK to work. Window manager is optional though.
    Without the window manager, FLTK apps (and all other GUI apps) will be borderless.

    You can start X yourself, then set the DISPLAY environment variable to just ":0.0",
    and then be able to run the FLTK app.


Ian MacArthur

unread,
Nov 4, 2020, 2:31:35 PM11/4/20
to fltkg...@googlegroups.com


> On 4 Nov 2020, at 19:17, Dave Branson wrote:
>
> I am opening a window, displaying a logo and launching a slider for input. Thanks.


OK - if you open a window, you need a display context, so for fltk under X11 that means X11 needs to be running or there will be no display server to provide that context.

If you want a “GUI application" that runs without X on the Pi, you might be able to do something with drawing directly to the framebuffer, but I’ve never actually done that; the Pi is powerful enough that I just run X always... (We used to run X display servers on 50MHz 486 terminals, so the Pi has plenty of oomph in comparison.)

There’s also a fltk port for nxlib, but TBH I find it better just to run X itself!

Dave Branson

unread,
Nov 4, 2020, 2:31:58 PM11/4/20
to fltk.general
Oh, and I am also using the position of the slider to control a fan's speed through GPIO and wiringPi.

Greg Ercolano

unread,
Nov 4, 2020, 2:50:14 PM11/4/20
to fltkg...@googlegroups.com

    If you want to start X yourself, first disable the default desktop from starting up automatically on your RPI
    so the machine boots to a text login console, so you can take over starting X yourself.

    Then create two scripts, for example:

        /usr/local/bin/my-start-x
        /usr/local/bin/my-start-apps

    Your rc.local would run that first script, /usr/local/bin/my-start-x, perhaps starting it in the background
    so it doesn't block the rest of your rc.local.

    The contents of /usr/local/bin/my-start-x would be:

#!/bin/sh
xinit  /usr/local/bin/my-start-apps  -xinit  --

    ..and the contents of my-start-apps would be:

#!/bin/sh
/path/to/your/fltk-app -arg1 -arg2 &

    What you should end up with is a plain X11 graphics screen, no window manager, just the default
    X environment. Your second script, 'my-start-apps' handles starting your FLTK application, which will
    inherit a DISPLAY variable that is already set, IIRC.

    Up to your app to handle window placement, as you'll have no window manager to let the user move
    stuff around (which is probably what you want), and there will be no window manager hot keys to let
    the user accidentally trigger window minimize/window close/etc, suitable for e.g. a kiosk or other dedicated
    function machine.

janezz55

unread,
Nov 26, 2020, 4:52:00 AM11/26/20
to fltk.general
cairo has a backend for the framebuffer:

cairo-directfb-surface.c
cairo-directfb.h

so, if you write a display driver for cairo (which was done in the NTK project), you will be able to run your application. Please share your work, a 100% working cairo display driver seems an elusive target.
Reply all
Reply to author
Forward
0 new messages