I've made some work to separate simulation part from FLTK.
I've separated libstage to two separate libraries: libstage-core and libstage. libstage-core implements headless simulation, and now it contains no references to FLTK. libstage includes libstage-core and FLTK implementation for GUI.
There are also two variants of executables: 'legacy' stage and stage-headless. Legacy variant works the same, with -gui option. stage-headless can only be headless, without any GUI.
Things that I have refactored to make it work:
Canvas now wraps most rendering routines, instead of calling FLTK GL utilities. FLTK-specific routines are implemented in CanvasFLTK class.
Menu and option system. I've stripped GUI code from Option class. All menu-related things are localized in MenuManager class. FLTK part implements MenuManagerFLTK, that links to CanvasFLTK to populate a menu
All rendering methods get a pointer to active canvas. No need to keep a pointer to world class, just to obtain canvas pointer in rendering pipeline. It would help to implement multi canvas rendering as well.
Image loading is localized in Image class. It uses libpng to load images. I haven't seen non-png bitmaps in world folder. Though I can consider making a more complex management of image loaders, allowing FLTK-based stage version to register additional fltk image loader.
I've made some work to separate simulation part from FLTK.
I've separated libstage to two separate libraries: libstage-core and libstage. libstage-core implements headless simulation, and now it contains no references to FLTK. libstage includes libstage-core and FLTK implementation for GUI.
There are also two variants of executables: 'legacy' stage and stage-headless. Legacy variant works the same, with -gui option. stage-headless can only be headless, without any GUI.
Things that I have refactored to make it work: