Howto:Start core development: Difference between revisions

Jump to navigation Jump to search
→‎Project architecture: Courtesy of Jim Wilson 2003: http://www.mail-archive.com/flightgear-devel@flightgear.org/msg16568.html
(→‎Project architecture: Courtesy of Jim Wilson 2003: http://www.mail-archive.com/flightgear-devel@flightgear.org/msg16568.html)
Line 89: Line 89:


The FG source tree is commonly referred to as $FG_SRC, while the SimGear source tree is often referred to as $SG_SRC.
The FG source tree is commonly referred to as $FG_SRC, while the SimGear source tree is often referred to as $SG_SRC.
A while ago, Jim Wilson posted the following advice on the devel list:
If you are familiar with C++ then you should have no trouble figuring things out.  Take a look at the SGSubsystem class.  This is the base for all the subsystems in flightgear.  The most frequently used functions in this class are the init and the update functions.
Then take time to look at a few subsystems.  Generally for most subsystems you can figure that the update function gets called once per frame.
The frame loop is in $FG_SRC/Main.cxx (function mainloop).  Here you will see the various subsystem's update calls and the sequence they are done in.  What I mean by frame loop is this loop is repeated for each frame (note the rendering down the bottom of it).  There is also an event subsystem that is used to schedule calls to update() of certain subsystems on a timer interval.
With this general overview (don't try to understand every line of code yet), you should be able to locate bits of code that you are interested in by
perusing the directories of modules.  Like I said most subsystems are based on SGSubsystem, so you should be able to locate implementations of init() and
update().  Also note that some subsystems are updated by others,  so if you don't see the update() called from in the mainloop then do a text search
through the modules to find the code that actually does call the update() (look for references to the class you are interested in).
Finally you will want to familiarize yourself with the data that is exposed in the property tree.  This is an excellent learning tool.  When running
FlightGear, bring up the Property browser from the file menu.  This property tree is essential for much of the way in which configuration and data output
are handled in FlightGear.  For example the flight instruments are all configured using xml defined references to values in the property tree in
order to position needles, etc. Changing property values can be used to alter the configured behavior of FlightGear at startup using parameters and/or xml declarations, or on the fly using C++ property class functions in the code or from several other interfaces including the property browser (for example: try adjusting the cloud layer settings in the property browser under environment/clouds, you will see the effect right away).
Speaking of instruments, you might want to take a look at how some of the instrumentation configuration (Aircraft/Instrumentation/*.xml files in the
base package) in order to get an idea of how different parts of flightgear can be configured to communicate with other parts in a certain way through the
property tree.  You can also look at the preferences.xml file to see an example of how startup configuration for various subsystems is handled through
the property tree.
By browsing the properties and tracing interesting data items to the code they are output from or read by, you can learn a lot about how FlightGear works.  When you see something interesting do a text search through the source code for that property name and you will find out how it is utilized.
Welcome aboard and do feel free to post any questions to the list as they come up.


= The source code =
= The source code =

Navigation menu