Howto:Use the Canvas in non-FG projects
| This article is a stub. You can help the wiki by expanding it. |
Using the Canvas in non-FG projects
The canvas system has been refactored such that it can be more easily re-used in other programs, this included moving the Canvas component from FlightGear to SimGear and releasing the canvas code under SimGear's license (LGPL).
It is now possible to use the Canvas in projects unrelated to FlightGear, but you will obviously benefit from using certain FlightGear-related technologies, such as an * property tree
- SGSubsystem/Mgr-based main loop
- an osgviewer-based main window
- Nasal scripting
Icecode's FGRadar project is such a completely separate code base from FG, which uses SG/FG components to simplify code reuse, without re-inventing the wheel.
For this very purpose, FGRadar uses a custom "SGApplication" framework - so that existing FlightGear subsystems can be more easily reused in different projects. All that's needed is deriving your own class from "SGApplication" and implementing its interface. The whole idea behind "SGApplication" is to provide a scriptable framework for OpenGL applications, fully based on 1) OSG, 2) SGSubsystems, 3) Nasal scripting and 4) the Canvas.
| the whole purpose of SGApplication is to provide a SGSubsystem-based "architecture" so that Nasal + Canvas and the property tree code can be easily reused.
— Hooray (Thu Apr 02). Re: Simgear-based subsystem with Canvas support?.
(powered by Instant-Cquotes) |
| the SGApplication stuff isn't really needed, we just came up with it to simplify working with the SG code. But at least it demonstrates how the whole SGSubsystemMgr stuff works.
— Hooray (Thu Apr 02). Re: Simgear-based subsystem with Canvas support?.
(powered by Instant-Cquotes) |
| you can also use SGSubsystem/SGSubsystemMgr directly - no need for "SGApplication" at all, it's just a convenicence helper.
"porting" isn't strictly necessary - you would primarily need int main() with a top-level SGSubsystemMgr, where you can then add the property tree, Nasal, Canvas, events etc (a handful of subsystems). To use Canvas outside FG, you would also need to look at the FGCanvasSystemAdapter in $FG_SRC/Canvas and provide your own wrapper for your own app (trivial). — Hooray (Thu Apr 02). Re: Simgear-based subsystem with Canvas support?.
(powered by Instant-Cquotes) |
| "fgpanel" is a code base that is using the "copy & paste" approach - so could serve as another example (beyond fgradar).
— Hooray (Thu Apr 02). Re: Simgear-based subsystem with Canvas support?.
(powered by Instant-Cquotes) |
For additional info, see: http://forum.flightgear.org/viewtopic.php?f=71&t=18415