Board index FlightGear Development Canvas

[solved] f-20 text issue : problem with dataset

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

[solved] f-20 text issue : problem with dataset

Postby Flying toaster » Wed Dec 19, 2012 8:52 pm

I am running into a problem with Canvas text

Image

Supposedly the clock IS red as shown in the following code :
Code: Select all
#Clock

var hour_prop = props.globals.getNode("sim/time/utc/hour", 1);
var minute_prop = props.globals.getNode("sim/time/utc/minute", 1);
var second_prop = props.globals.getNode("sim/time/utc/second", 1);



var clock = canvas.new({
  "name": "Clock",
  "size": [128, 128],
  "view": [128, 128],
  "mipmapping": 1   
});

clock.setColorBackground(1.0,0.0,0);

clock.addPlacement({"node": "Clock"});

var clockRoot = clock.createGroup();

var clockText = clockRoot.createChild("text")
                      .setTranslation(64, 128)   
                      .setAlignment("center-bottom")
                      .setFont("led.txf")
                      .setFontSize(24, 1.2)
                      .setColor(1.0,0.0,0.0)
                      .show();                                                 
var minutes = 0;
var seconds = 0;
var display_time = "";

var updateClock = func
{
 minutes = minute_prop.getValue();
 seconds = second_prop.getValue();
 
 #add leading zeros
 if (seconds < 10)
   display_time = sprintf (":0%i",seconds);
 else
  display_time = sprintf (":%i",seconds);
 
 if (minutes < 10)
   display_time = sprintf (":0%i%s",minutes,display_time);
 else
  display_time = sprintf (":%i%s",minutes,display_time);
 
 clockText.setText(sprintf("%i%s",hour_prop.getValue(), display_time)); 
}



What I am doing wrong ?
Last edited by Flying toaster on Sat Jan 05, 2013 3:59 pm, edited 1 time in total.
Flying toaster
 
Posts: 390
Joined: Wed Nov 29, 2006 7:25 am
Location: Toulouse France

Re: Text color

Postby TheTom » Thu Dec 20, 2012 12:34 am

That's strange. I've copied your code to my aircraft and it works without problems (if I set a text) aka. it creates red text on a red canvas. Is your aircraft somewhere available such that I can have a look at it? Also, what version of FlighGear are you using?
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Text color

Postby Flying toaster » Thu Dec 20, 2012 7:29 am

Oops :oops:

Sorry for the red on red, I was just playing with colors to see if it had any effect at all.

I am using a git version from 2 days ago (I found the canvas support a bit patchy on 2.8 ). It happens with Rembrandt on or off.

Here is a link to the current (very alpha) package of the F-20

F-20 alpha package

This package still looks a bit better without Rembrandt (too many shadows in the cockpit + problem with de-saturated colors)

Thanks for the help

Happy holiday season !
Flying toaster
 
Posts: 390
Joined: Wed Nov 29, 2006 7:25 am
Location: Toulouse France

Re: Text color

Postby TheTom » Thu Dec 20, 2012 11:39 am

Now it's getting really strange:
Image
Its working with and without rembrandt. Do you have any special setup? What operating system are you using? And also what version of OpenSceneGraph are you using?
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: Text color

Postby Flying toaster » Thu Dec 20, 2012 6:34 pm

Errr

Linux Ubuntu 12.04
OSG 3.0.1
Nothing else is special as far as I can tell...

Strange indeed
Flying toaster
 
Posts: 390
Joined: Wed Nov 29, 2006 7:25 am
Location: Toulouse France

Re: Text color

Postby Hooray » Thu Dec 20, 2012 6:53 pm

I just tested this in a Lubuntu 12.04 32bit VM (which is the reason for the frame rate and the frame spacing), and it's working properly here:
Image

(Using nvidia hardware)
what's your graphics card/driver version (proprietary/OSS)?
do you see the same issue when using Windows on the same computer (if that's an option) ?

Try the new about dialog to get all required information:
Image
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: Text color

Postby Flying toaster » Thu Dec 20, 2012 7:22 pm

Now I will sound like a newbie, but how do you get that complete "about"dialog (I only get a very basic one).
Actually If I look at the configuration of my rig, the only obvious difference is that you are using OSG 3.1 when I use OSG 3.0

My GPU is a GeForce GTX550Ti, not top notch but still should do the trick ;)
Flying toaster
 
Posts: 390
Joined: Wed Nov 29, 2006 7:25 am
Location: Toulouse France

Re: Text color

Postby Hooray » Thu Dec 20, 2012 8:23 pm

The extended about dialog should be available already if you are using git.
It sounds to me like you are using mismatching FGFS<->FGDATA versions here ?
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: Text color

Postby Flying toaster » Thu Dec 20, 2012 10:08 pm

You nailed it :oops:

Thanks a lot !

Back to work
Flying toaster
 
Posts: 390
Joined: Wed Nov 29, 2006 7:25 am
Location: Toulouse France


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest