FlightGear Headless: Difference between revisions

Jump to navigation Jump to search
(9 intermediate revisions by 2 users not shown)
Line 4: Line 4:


= FlightGear Headless =
= FlightGear Headless =
{{Main article|Supporting multiple renderers}}
there is no document listing the minimum set of stable features. If someone wants to write one, they can do it, but I guess they won’t volunteer to test release candidates against it; indeed getting people to even run them has been a struggle.<ref>{{cite web
  |url    =  https://sourceforge.net/p/flightgear/mailman/message/35990557/
  |title  =  <nowiki> Re: [Flightgear-devel] carrier features: is there any modification ,
your policy related ? </nowiki>
  |author =  <nowiki> James Turner </nowiki>
  |date  =  Aug 10th, 2017
  |added  =  Aug 10th, 2017
  |script_version = 0.40
  }}</ref>
with the new test framework it should be possible to add tests for carrier start, as I already did to ensure runway selection with METAR. Indeed the position init code is a very good candidate for testing this way since we broken different aspects (parking position startup, WXR runway selection, the carrier, probably some more things<ref>{{cite web
  |url    =  https://sourceforge.net/p/flightgear/mailman/message/35990557/
  |title  =  <nowiki> Re: [Flightgear-devel] carrier features: is there any modification ,
your policy related ? </nowiki>
  |author =  <nowiki> James Turner </nowiki>
  |date  =  Aug 10th, 2017
  |added  =  Aug 10th, 2017
  |script_version = 0.40
  }}</ref>


The original FG scene graph design is based on rigid assumptions of the ordering of the sequence of events for start up and shut down. Branch management is highly inconsistent, and is scattered all over the flightgear and simgear codebases. But it worked perfectly due to the fixed event sequences. The new subsystem design however brings in a much more flexible design, whereby systems can be dynamically turned on, turned off, restarted, initialised, reinitialised, etc. This is essential for enabling rebooting, and allows for custom FlightGear usage of only a small subset of systems and for '''a headless mode'''. The OSG+subsystem breakage occurred once the scene manager subsystem was fully converted to the new design. The OSG scene graph root is created at the start of FGScenery::init(). With the subsystem design, the scene graph root may not be present when other flightgear/simgear code paths are called to create, manage, or destroy the various scene graph branches.<ref>{{cite web
The original FG scene graph design is based on rigid assumptions of the ordering of the sequence of events for start up and shut down. Branch management is highly inconsistent, and is scattered all over the flightgear and simgear codebases. But it worked perfectly due to the fixed event sequences. The new subsystem design however brings in a much more flexible design, whereby systems can be dynamically turned on, turned off, restarted, initialised, reinitialised, etc. This is essential for enabling rebooting, and allows for custom FlightGear usage of only a small subset of systems and for '''a headless mode'''. The OSG+subsystem breakage occurred once the scene manager subsystem was fully converted to the new design. The OSG scene graph root is created at the start of FGScenery::init(). With the subsystem design, the scene graph root may not be present when other flightgear/simgear code paths are called to create, manage, or destroy the various scene graph branches.<ref>{{cite web
Line 16: Line 38:
</ref>
</ref>


Another option is to make FGRenderer the optional piece - James Turner started doing some work in this direction in December 2015. I.e without FGRenderer there is no rendering at all, and hence no scene-graph.<ref>{{cite web
Another option is to make [[The FlightGear Rendering Pipeline|FGRenderer]] the optional piece - James Turner started doing some work in this direction in December 2015. I.e without FGRenderer there is no rendering at all, and hence no scene-graph.<ref>{{cite web
   |url    = https://sourceforge.net/p/flightgear/mailman/message/35064249/
   |url    = https://sourceforge.net/p/flightgear/mailman/message/35064249/
   |title  = <nowiki>Re: [Flightgear-devel] Integration of the new subsystem design and
   |title  = <nowiki>Re: [Flightgear-devel] Integration of the new subsystem design and
Line 32: Line 54:
* virtual void shutdownVisuals();  
* virtual void shutdownVisuals();  


With the expectation that the manager layer (FGScenery or FGRenderer) calls initVisuals / updateVisuals / shutdownVisuals if it exists. This also forces the implementation of each subsystem to distinguish simulation pieces (modifies properties) from display pieces (reads but hopefully does not modify properties, modifies OSG state) <ref>{{cite web
With the expectation that the manager layer (FGScenery or FGRenderer) calls initVisuals / updateVisuals / shutdownVisuals if it exists. This also forces the implementation of each subsystem to distinguish simulation pieces (modifies properties) from display pieces (reads but hopefully does not modify properties, modifies OSG/rendering state, i.e. visuals) <ref>{{cite web
   |url    = https://sourceforge.net/p/flightgear/mailman/message/35064249/
   |url    = https://sourceforge.net/p/flightgear/mailman/message/35064249/
   |title  = <nowiki>Re: [Flightgear-devel] Integration of the new subsystem design and
   |title  = <nowiki>Re: [Flightgear-devel] Integration of the new subsystem design and
Line 135: Line 157:


== Proof of concept (patch) ==
== Proof of concept (patch) ==
{{Note|This will not actually disable rendering, but merely hide the window by rendering to a pbuffer}}
{{Note|This will not actually disable rendering, but merely hide the window by rendering to a pbuffer (FBO)}}
The main camera is created in CameraGroup::buildCamera and a pbuffer is allocated when you set osg::GraphicContext::Traits.pbuffer to true. These traits are available in buildCamera because we set width and height there. For debugging purpose, you can add a line like
The main camera is created in CameraGroup::buildCamera and a pbuffer is allocated when you set osg::GraphicContext::Traits.pbuffer to true. These traits are available in buildCamera because we set width and height there. For debugging purpose, you can add a line like
<syntaxhighlight lang="cpp">window->gc->getTraits()->pbuffer=true;
<syntaxhighlight lang="cpp">window->gc->getTraits()->pbuffer=true;
Line 144: Line 166:
   }}
   }}
</ref>
</ref>
<syntaxhighlight lang="diff">
diff --git a/src/Main/options.cxx b/src/Main/options.cxx
index db5d84d..fb63dd1 100644
--- a/src/Main/options.cxx
+++ b/src/Main/options.cxx
@@ -1797,6 +1797,7 @@ struct OptionDesc {
    {"prop",                        true,  OPTION_FUNC | OPTION_MULTI,  "", false, "", fgOptSetProperty},
    {"load-tape",                    true,  OPTION_FUNC,  "", false, "", fgOptLoadTape },
    {"developer",                    true,  OPTION_IGNORE | OPTION_BOOL, "", false, "", nullptr },
+    {"enable-headless",              false, OPTION_BOOL, "/sim/startup/headless-mode", true, "",0 },
    {0}
};
diff --git a/src/Viewer/WindowBuilder.cxx b/src/Viewer/WindowBuilder.cxx
index f4d3c33..a1ffb84 100644
--- a/src/Viewer/WindowBuilder.cxx
+++ b/src/Viewer/WindowBuilder.cxx
@@ -149,6 +149,12 @@ void WindowBuilder::makeDefaultTraits(bool stencil)
            SG_LOG(SG_VIEW,SG_DEBUG,"Using initial window size: " << w << " x " << h);
        }
    }
+bool headless = fgGetBool("/sim/startup/headless-mode", false);
+if (headless) {
+ SG_LOG(SG_VIEW, SG_ALERT, "Headless view required: rendering window to pbuffer");
+ traits->pbuffer = true;
+} // enable headless
+
}
   
} // of namespace flightgear
</syntaxhighlight>


For reference, to disable the window. It's the last thing before the return statement in WindowBuilder::makeDefaultTraits(bool stencil):
For reference, to disable the window. It's the last thing before the return statement in WindowBuilder::makeDefaultTraits(bool stencil):
Line 386: Line 441:


== Milestones ==
== Milestones ==
* allow FlightGear to be run without creating a visible GUI window, i.e. in "headless" mode, using a --headless parameter {{Pending}}
* allow FlightGear to be run without creating a visible GUI window, i.e. in "headless" mode, using a --headless parameter {{Done}}
* allow FlightGear to be optionally compiled and run without any sound support/dependencies (OpenAL) {{Done}}
* allow FlightGear to be optionally compiled and run without any sound support/dependencies (OpenAL) {{Done}}
* allow replay buffers to be saved to a file in order to be replayed for automated test/demo flights, so that users can share saved replay buffers when reporting a bug {{Done}} (supported via the flight recorder subsystem)
* allow replay buffers to be saved to a file in order to be replayed for automated test/demo flights, so that users can share saved replay buffers when reporting a bug {{Done}} (supported via the flight recorder subsystem)
Line 397: Line 452:
* http://forum.flightgear.org/viewtopic.php?f=18&t=19502&p=179978&hilit=#p179968
* http://forum.flightgear.org/viewtopic.php?f=18&t=19502&p=179978&hilit=#p179968
* https://code.google.com/p/flightgear-bugs/issues/detail?id=882
* https://code.google.com/p/flightgear-bugs/issues/detail?id=882
* {{flightgear commit|af6611d7f61a6d993ce94fa6efade0b4485eb7a5}}


== Devel List ==
== Devel List ==
Line 403: Line 459:
* http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg29907.html
* http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg29907.html
* http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg02028.html
* http://www.mail-archive.com/flightgear-devel@lists.sourceforge.net/msg02028.html
== References ==
{{Appendix}}


[[Category:Core development projects]]
[[Category:Core development projects]]

Navigation menu