Board index FlightGear Support Graphics

OSG Text differences in Linux & Windows

Graphics issues like: bad framerates, weird colors, OpenGL errors etc. Bad graphics ar usually the result of bad graphics cards or drivers.
Forum rules
In order to help you, we need to know a lot of information. Make sure to include answers to at least the following questions in your initial post.

- what OS (Windows Xp/Vista, Mac etc.) are you running?
- what FlightGear version do you use?
- what graphics card do you have?
- does the problem occur with any aircraft, at any airport?
- is there any output printed to the console (black window)?
- copy&paste your commandline (tick the "Show commandline box on the last page of FGRun or the "Others" section on the Mac launcher).
- please upload a screenshot of the problem.

If you experience FlightGear crashes, please report a bug using the issue tracker (can be also used for feature requests).
To run FlightGear on old computers with bad OpenGL support, please take a look at this wiki article. If you are seeing corrupted/broken textures, please see this article.

Note: If you did not get a reponse, even after 7 days, you may want to check out the FlightGear mailing lists to ask your question there.

OSG Text differences in Linux & Windows

Postby Avionyx » Wed Sep 04, 2019 7:34 am

Hi all,

I'm running Flightgear 2018.3.2 with the ALS renderer in Ubuntu 19.04 from Saikrishna Arkot's stable build PPA using an nVidia GTX 970 with the latest proprietary drivers.

It's come to light that the visual representation of OSG Text (I believe it's OSG text anyway) that I see is different to that of others using Windows machines - I've verified this myself using FG 2018.3.2 on a Windows 10 machine.

The problem is that OSG text seems to display somewhat OK but only have a very limited colour animation.

This is the Master warning lights in correct operation on Windows 10, Yellow text for active lights and the non active lights are dimmed to near black
Image

Here's the same situation on my Linux machine, all of the warning/caution lights are constantly White regardless of the state. If they become Active then they are simply just a very slightly brighter white:

Image
Image

It doesn't seem to be related directly to emissions/animations as they are working fine on the instruments, just not on the text.

To compare it's not just limited to this aircraft I've checked others that use OSG text and it would seem to be the same. Here on this helicopter the warning panel is supposed to have coloured text also:
Image

I've tried changing the colours slightly to see if it just didn't like a particular combination but no luck with that either.
Here is the XML from the Harrier GR9 (First 3 images of this thread) showing how it's currently set up.

Code: Select all
<?xml version="1.0"?>

<!-- comms panel -->

<PropertyList>

 <!--  master warn panel -->

 <!-- Unlit -->

 <text>
  <name>WARN1</name>
  <font>lcd.txf</font>
  <character-size type="double">0.006</character-size>
  <offsets>
     <x-m>2.653</x-m>
     <y-m>-0.158</y-m>
     <z-m>0.717</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">WARN</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>

 <text>
  <name>MASTER1</name>
  <font>lcd.txf</font>
  <character-size type="double">0.006</character-size>
  <offsets>
     <x-m>2.653</x-m>
     <y-m>-0.16</y-m>
     <z-m>0.725</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">MASTER</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <text>
  <name>fuel1a</name>
  <font>lcd.txf</font>
  <character-size type="double">0.0064</character-size>
  <offsets>
     <x-m>2.654</x-m>
     <y-m>-0.151</y-m>
     <z-m>0.684</z-m>
   <roll-deg>-90</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">F U E L</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>

 <text>
  <name>fuel2a</name>
  <font>lcd.txf</font>
  <character-size type="double">0.0064</character-size>
  <offsets>
     <x-m>2.654</x-m>
     <y-m>-0.132</y-m>
     <z-m>0.684</z-m>
   <roll-deg>-90</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">F U E L</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <text>
  <name>sec</name>
  <font>lcd.txf</font>
  <character-size type="double">0.005</character-size>
  <offsets>
     <x-m>2.655</x-m>
     <y-m>-0.157</y-m>
     <z-m>0.649</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">15 SEC</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


  <text>
  <name>mfs</name>
  <font>lcd.txf</font>
  <character-size type="double">0.005</character-size>
  <offsets>
     <x-m>2.655</x-m>
     <y-m>-0.154</y-m>
     <z-m>0.633</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">MFS</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>

 <text>
  <name>bingo1</name>
  <font>lcd.txf</font>
  <character-size type="double">0.005</character-size>
  <offsets>
     <x-m>2.656</x-m>
     <y-m>-0.155</y-m>
     <z-m>0.619</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">BINGO</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <text>
  <name>water</name>
  <font>lcd.txf</font>
  <character-size type="double">0.005</character-size>
  <offsets>
     <x-m>2.656</x-m>
     <y-m>-0.154</y-m>
     <z-m>0.603</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">H2O</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <!-- lit versions -->

   <animation>
  <type>material</type>
  <object-name>MASTER</object-name>
   <object-name>WARN</object-name>
    <object-name>fuel1</object-name>
   <object-name>fuel2</object-name>


   <object-name>bingo</object-name>


  <ambient>
    <red>1</red>
    <green>0</green>
    <blue>0.0</blue>
  </ambient>
  <diffuse>
    <red>0.8</red>
    <green>0.8</green>
    <blue>0.0</blue>
  </diffuse>
  <emission>
    <red>1</red>
    <green>1</green>
    <blue>0.0</blue>
  </emission>
 </animation>

  <text>
  <name>WARN</name>
  <font>lcd.txf</font>
  <character-size type="double">0.006</character-size>
  <offsets>
     <x-m>2.6531</x-m>
     <y-m>-0.158</y-m>
     <z-m>0.717</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">WARN</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>

 <text>
  <name>MASTER</name>
  <font>lcd.txf</font>
  <character-size type="double">0.006</character-size>
  <offsets>
     <x-m>2.6531</x-m>
     <y-m>-0.16</y-m>
     <z-m>0.725</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">MASTER</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <text>
  <name>fuel1</name>
  <font>lcd.txf</font>
  <character-size type="double">0.0064</character-size>
  <offsets>
     <x-m>2.6541</x-m>
     <y-m>-0.151</y-m>
     <z-m>0.684</z-m>
   <roll-deg>-90</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">F U E L</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>

 <text>
  <name>fuel2</name>
  <font>lcd.txf</font>
  <character-size type="double">0.0064</character-size>
  <offsets>
     <x-m>2.6541</x-m>
     <y-m>-0.132</y-m>
     <z-m>0.684</z-m>
   <roll-deg>-90</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">F U E L</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>




<text>
  <name>bingo</name>
  <font>lcd.txf</font>
  <character-size type="double">0.005</character-size>
  <offsets>
     <x-m>2.6561</x-m>
     <y-m>-0.155</y-m>
     <z-m>0.619</z-m>
   <roll-deg>0</roll-deg>
  </offsets>
  <axis-alignment>yz-plane</axis-alignment>
  <type type="string">literal</type>
  <text type="string">BINGO</text>
  <draw-text type="bool">true</draw-text>
  <alignment>left-top</alignment>
 </text>


 <!-- Animations -->

 <animation>
        <type>select</type>
       <object-name>MASTER</object-name>
   <object-name>WARN</object-name>
    <object-name>fuel1</object-name>
   <object-name>fuel2</object-name>
        <condition>
         <less-than>
            <property>consumables/fuel/total-fuel-lbs</property>
                  <value>2000</value>
               </less-than>

         </condition>
    </animation>

   <animation>
        <type>select</type>
       <object-name>bingo</object-name>

        <condition>
         <less-than>
            <property>consumables/fuel/total-fuel-lbs</property>
                  <value>1200</value>
               </less-than>

         </condition>
    </animation>


</PropertyList>



Any and all help would be much appreciated.
Alex
Avionyx
 
Posts: 531
Joined: Mon Jan 11, 2010 4:07 pm
Location: EGMD
Callsign: G-AVYX
Version: 2020.4
OS: Manjaro

Re: OSG Text differences in Linux & Windows

Postby legoboyvdlp » Wed Sep 04, 2019 7:42 am

On Linux (and Windows, but the release from flightgear.org already has this) you want to use this OSG repo:
GitHub.com/zakalawe/OSG

Make sure you use branch fgfs-342-1
User avatar
legoboyvdlp
 
Posts: 7981
Joined: Sat Jul 26, 2014 2:28 am
Location: Northern Ireland
Callsign: G-LEGO
Version: next
OS: Windows 10 HP

Re: OSG Text differences in Linux & Windows

Postby Thorsten » Wed Sep 04, 2019 9:58 am

If you have a chance to replace OSGText by canvas - do so. OSGText (even with the custom OSG repository) does not play nice with our Effects and Shaders framework and will continue to have issues for all eternity.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: OSG Text differences in Linux & Windows

Postby Hooray » Wed Sep 04, 2019 6:33 pm

Regarding Thorsten's comments, that's true: As a matter of fact, there's been the long-standing idea (and some discussion surrounding that), to replace/re-implement the original osgText/XML implementation in FlightGear by something Canvas-driven, i.e. using a canvas back-end, this could even be handled in scripting space, this would also mean that the corresponding code paths are unified, which also means less code, and more robust features. For details, look for comments by James Turner who originally tinkered with the idea of re-implementing the 2D rendering back-end by using a corresponding canvas-based wrapper, to map important 2D features using legacy code to a Canvas back-end instead.

http://wiki.flightgear.org/Unifying_the ... via_canvas

As you can see, this would involve writing parsers for our existing 2D panels/HUD code to map such features to the Canvas system. To make this work for some legacy features (e.g. osgText/XML) it would make sense to introduce a handful of hooks/helper functions to provide a mechanism to register a canvas re-implementation, so that certain functionality can be delegated to scripting space.

In the case of PUI (the legacy GUI) we simply ended up using a fgcommand based wrapper to trigger the scripted re-implementation, that way the native C++ based legacy code is entirely ignored. This would also be feasible (and even straightforward to do for any other legacy 2D code, including the HUD, 2D panels and the osgText animation).

It's really not much more than 15 lines of almost identical C++ to register new hooks and dispatch such functionality to scripting space.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: OSG Text differences in Linux & Windows

Postby Avionyx » Thu Sep 05, 2019 11:17 am

Thank you for the reply gentlemen.
It does seem then, that Canvas is the way to go. What's the best way for me to learn by actually doing then? If we take the problem at hand as an example and I wanted to replace the "Bingo" text with a Canvas alternative that displayed a nice glowing Yellow text when the fuel level was below 1100lbs.

Just as an idea, what's it going to take for someone who's never made canvas work correctly before to implement that into a aircraft I'm trying to improve?

Many thanks in advance

Alex
Avionyx
 
Posts: 531
Joined: Mon Jan 11, 2010 4:07 pm
Location: EGMD
Callsign: G-AVYX
Version: 2020.4
OS: Manjaro

Re: OSG Text differences in Linux & Windows

Postby Thorsten » Thu Sep 05, 2019 11:31 am

If we take the problem at hand as an example and I wanted to replace the "Bingo" text with a Canvas alternative that displayed a nice glowing Yellow text when the fuel level was below 1100lbs.


Basically a canvas is a texture that can be written runtime, so the first step is to create a properly uv-mapped surface onto which the canvas text is written.

Say that surface is called 'event-timer-glass' (that's an example from the Shuttle) - to display digits or backlit text, you'd typically make the surface transparent above a background and just write non-transparent text onto it.

This code snippet ( from Aircraft/SpaceShuttle/Nasal/housekeeping.nas)

Code: Select all
# create a canvas corresponding to a 256 x 256 texture

var dev_canvas= canvas.new({
                "name": "Timer",
                    "size": [256,256],
                    "view": [256,256],                       
                    "mipmapping": 0     
                    });

# assign the canvas to the surface in the 3d model

   dev_canvas.addPlacement({"node": "event-timer-glass"});

# set background color

   dev_canvas.setColorBackground(0,0,0,0);

# create a group to add elements to the canvas

   var root = dev_canvas.createGroup();

# create a text object inside the group, set colors and fonts

   var time_string = root.createChild("text")
         .setText("00:00")
                  .setColor(1,0.5,0.1)
   .setFontSize(24)
   .setScale(2.5,6)
   .setFont("DSEG/DSEG7/Classic-MINI/DSEG7ClassicMini-Bold.ttf")
   .setAlignment("center-bottom")
   .setTranslation(130, 210);


creates a text on the canvas.

Whenever you want to change the text, you do

Code: Select all
time_string.setText(my_new_text)


whenever you want to change text color, you do

Code: Select all
time_string.setColor(r,g,b);


Now, the surface you've created is for the renderer just a normal textured surface - so you can add emission animation to make it light up. But you can also assign effects - for instance the ALS display effect can give you some over-saturated glow dependent on lighting conditions to give the appearance of backlit digital readouts, or it can mesh with internal shadows if you simulate them.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: OSG Text differences in Linux & Windows

Postby Richard » Thu Sep 05, 2019 11:46 am

Avionyx wrote in Thu Sep 05, 2019 11:17 am:Just as an idea, what's it going to take for someone who's never made canvas work correctly before to implement that into a aircraft I'm trying to improve?


A while back I wrote an article for FGUK Using canvas in a 3d instrument http://chateau-logic.com/content/flightgear-using-canvas-3d-instrument that covers the basics of getting canvas connected to a texture that is then displayed on a 3d object.

So just get this going and then make an SVG with all of your required text - and then it's a case of doing the following to change the text

Code: Select all
bingoElement = svg.getElementById("svg-item-name");
bingoElement.setFont(font).setFontSize(size,ratio);

updateLoop = func (
bingoElement.setText("SOME TEXT");
}


I'd recommend using a large-ish texture for all of the text in the cockpit and share it between multiple 3d objects.

What you have to remember is that Canvas enables you to draw straight onto a texture; so it is then a case of mapping the texture to the 3d object.
Richard
 
Posts: 810
Joined: Sun Nov 02, 2014 11:17 pm
Version: Git
OS: Win10

Re: OSG Text differences in Linux & Windows

Postby Hooray » Thu Sep 05, 2019 9:22 pm

Note that for anything resembling tooltip-like functionality that there is not only a dedicated Canvas-based API (and fgcommand based wrapper around it) available, but also a dedicated default/standard texture for GUI placements, for details refer to the "desktop" placement - which is how GUI dialogs and tooltips are shown by the Canvas GUI system.

Speaking in general, I would definitely suggest to start by tinkering with the Tooltip API (wiki), and then take it from there by looking at the underlying Canvas code/APIs, including transparent/invisible dialogs.

The tooltip API is fairly simple, and the nice thing about it is that you don't need to know any Canvas/Nasal stuff at all.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU


Return to Graphics

Who is online

Users browsing this forum: No registered users and 4 guests