User:Callahanp/Flightgear and Simgear Code/From Command Line to Holding Short: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 48: Line 48:
| 3. || Viewer/fg_os_osgviewer.cxx || int fgOSMainLoop()  
| 3. || Viewer/fg_os_osgviewer.cxx || int fgOSMainLoop()  
|
|
fgOSMainLoop doesn't do initializations itself.  In fact it is still around for the full duration of the flightgear session.  After marshalling initializations, including those for subsystems, it calls the fgMainLoopfgMain lowhere  is responsible for the third stage of initialization.  While its doing initializations it displays the splash screen and messages. Once that's done, it continues sd a driver for everything that happens afterwards. It's amazingly brief, Just four C++ statements on 12 lines of code.
fgOSMainLoop doesn't do initialization itself.  fgOSMainLoop is ''the'' main loop for the full duration of the flightgear session. It's amazingly brief, Just four C++ statements on 12 lines of code. The loop has just two tasks: Think of them  as "set up what has to be displayed" and "display it"During initialization, the setup task is initialization.  The second task displays the splash screen, messages produced by the initialization and something that moves to indicate that the program is still working. Then, after initialization, the setup part of the loop does the calculation work needed for the next frame of the simulation.  The display task then uses that data to show the simulation on the screen.


During Initialization Stage 3, fgOSMainLoop calls a routine to do initializations through a pointer, *idleFunc.  During Stage 3, *idleFunc points to fgIdleFunction.
fgIdleFunction does the initialization work. fgMainLoop() handles the events and calculations for the ongoing simulation. These are called through a pointer named *idlefunc. 
Initializations are done by repeatedly calling fgIdleFunction through the *idleFunc pointer.   
The display part of the loop is the same for both of these "setup" functions.
 
fgIdleFunction is the third stage of initialization.  During this stage, fgOSMainLoop calls fgIdleFunction repeatedly through *idleFunc.  Each call to fgIdleFunction does a different part of the initialization. In between, the splash screen is being updated, showing which part of the initialization is in progress, and a moving progress bar to show that "something" is happening.
When the third stage is complete, *idleFunc is set to point to fgOSMainLoop.
   
|-
|-
| 3. || Main/main.cxx || static void fgIdleFunction ( void )
| 3. || Main/main.cxx || static void fgIdleFunction ( void )
Line 58: Line 62:
|-
|-
| 4. || main/main.cxx || fgMainLoop  
| 4. || main/main.cxx || fgMainLoop  
| fgMainLoop does not contain a loop, its running under the loop in fgOSMainLoop and will continue to run in that loop until you reset or exit flightgear.  fgMainLoop handles the fourth and final stage of initialization, waiting on the loading of scenery, the airport and the aircraft data.  All the work is handled by subsystems loaded in earlier stagesThe subsystems continue to run after all that's done, and we find ourselves in position at the airport and ready to fly.   
| fgMainLoop does not contain a loop, its running under the loop in fgOSMainLoop and will continue to run in that loop until you reset or exit flightgear.  fgMainLoop handles the fourth and final stage of initialization, waiting on the loading of scenery, the airport and the aircraft data.  All the final initialization work is handled by subsystems loaded in stage threeUntil all subsystems are fully initialized, the splash screen continues to be displayed.  Once they're all ready, the subsystems continue to run, and we find ourselves in position at an airport and ready to fly.   


|}
|}
After initialization all of the subsystems needed to fly will be invoked as needed by fgMainLoop, run repeatedly in the actual loop in fgOSMainLoop.
After initialization all of the subsystems needed to fly will continue to be invoked as needed by fgMainLoop, which is run repeatedly in the actual loop in fgOSMainLoop.
 
At first glance, one might think that the naming of things in this part of Flightgear is a bit off.  The names might have made sense at one point in the early development of Flightgear, but things have changed and some functionality moved, but the names were not changed.  So we end up with things like fgMainLoop that does not contain a loop.  Does it matter? Probably not.  There's other work to do that's more important.  My guess is that we just need to know how this loop works and most of the time our attention will be much further down the call stack, inside one of those sub-systems.
 
 
Question:
Question:


What in the code finally recognizes that we're ready to display the scene in stage 4?
What in the code finally recognizes that we're ready to display the scene in stage 4?
Are the final initializations done by subsystems done in any particular order?
Are the final initializations done by subsystems done in any particular order?


Is what's above this point enough to know about startup and initialization?
The material below are detailed notes from an initial look at the main loop.  They're just lists of what gets done where.  Would a new developer just read the actual functions and make their own notes?
|-
|-
|  
|  
936

edits

Navigation menu