Canvas wrappers: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
(Switch to {{flightgear source}} and {{flightgear url}} to fix the broken Gitorious links.)
Line 27: Line 27:


We need to reimplement the 2D panel code in $FG_SRC/Cockpit/
We need to reimplement the 2D panel code in $FG_SRC/Cockpit/
* [https://gitorious.org/fg/flightgear/blobs/next/src/Cockpit/panel_io.cxx panel_io.cxx]
* {{flightgear source|src/Cockpit/panel_io.cxx|text=panel_io.cxx}}
* [https://gitorious.org/fg/flightgear/blobs/next/src/Cockpit/panel.cxx panel.cxx]
* {{flightgear source|src/Cockpit/panel.cxx|text=panel.cxx}}
* $FG_ROOT/Docs/README.xmlpanel
* $FG_ROOT/Docs/README.xmlpanel


Note that the FGPanel code is a bit cleaner than the old code, i.e. see [https://gitorious.org/fg/flightgear/blobs/next/src/Cockpit/panel.cxx#line366].
Note that the FGPanel code is a bit cleaner than the old code, i.e. see [{{flightgear url|src/Cockpit/panel.cxx|line=366}}].


Write a Nasal module that will take our existing instruments in $FG_AIRCRAFT/Instruments and turn them into canvases. Namely, that means, parsing:
Write a Nasal module that will take our existing instruments in $FG_AIRCRAFT/Instruments and turn them into canvases. Namely, that means, parsing:

Revision as of 10:45, 9 March 2016


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.

HUDs

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:

Cquote1.png 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.[1]
— James Turner
Cquote2.png
  1. James Turner (Tue, 24 Jul 2012 10:36:26 -0700). Re: [Flightgear-devel] Switching from PUI to osgWidget.


Also see Howto:Parsing 2D Instruments using the Canvas

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 [1].

Write a Nasal module that will take our existing instruments in $FG_AIRCRAFT/Instruments and turn them into canvases. Namely, that means, parsing:

  • params
  • layers
  • transformations
  • conditions
  • actions

Basically, we should already have all building blocks in place, because:

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.