| The FlightGear forum has a
subforum related to: Canvas
The canvas subsystem is entirely implemented on top of the property tree, so it does not depend on Nasal scripting. However, it is Nasal scripting which makes the Canvas system really flexible and powerful.
Currently, there are a number of efforts being discussed to unify the 2D rendering backends in FlightGear (2D panel, HUD, GUI etc) to ensure that the Canvas system is the common backend for all these needs, which will reduce the amount of legacy C++ code that we have in FlightGear for these things, while also paving the way towards better overall OpenGL compatibility, better maintainability and more optimization opportunities.
Directly working with the canvas via the property tree is possible but tedious, that's why there is a special generic Nasal wrapper to simplify working with canvases. However, to cater for more specific 2D drawing needs, there are going to be additional wrappers provided on top of the main canvas.nas module.
The purpose of this page is to determine the requirements for each wrapper.
The HUD module will be specifically targeted at developing HUDs.
2D Instruments parser
The 2D panel module will reimplement the existing 2D panel functionality in Canvas/Nasal space, so that the legacy C++ code can be slowly phased out:
|I'm even more convinced now that we should move the 2D panel and HUD rendering
over to this approach, since that would get rid of all the legacy OpenGL code
besides the GUI.
— James Turner
- James Turner (Tue, 24 Jul 2012 10:36:26 -0700). Re: [Flightgear-devel] Switching from PUI to osgWidget.
We need to reimplement the 2D panel code in $FG_SRC/Cockpit/
Note that the FGPanel code is a bit cleaner than the old code, i.e. see .
Write a Nasal module that will take our existing instruments in $FG_AIRCRAFT/Instruments and turn them into canvases. Namely, that means, parsing:
Basically, we should already have all building blocks in place, because:
- PropertyList-XML parsing support via io.nas
- we have support for raster images: Canvas Image
- Texture maps are also supported Howto:Using_raster_images_and_nested_canvases#Texture_Maps
- event handling: Canvas - Event Handling
- SGCondition bindings in Nasal (props.nas)
- support for layers via Canvas groups
- transformation can be directly handled through manipulation the tf properties
- bindings/actions would be directly turned into Nasal callbacks
In fact, the combination of Nasal and the Canvas is so much more flexible than our existing panel code, that it is foreseeable that it will see useful additions, which is why it'd be a good idea to introduce an optional version tag, so that new instruments can directly use canvas features.