Board index FlightGear Development Canvas

Changing canvas parameters after creation  Topic is solved

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.

Changing canvas parameters after creation

Postby merspieler » Fri Mar 12, 2021 11:04 pm

Is is possible to change canvas parameters like mipmapping after canvas creation? And if so, how do I do that?

I'd like to do something like this:
Code: Select all
# Create Canvas
var myCanvas = canvas.new({
    "name": "Test",
    "view": [width, height],
    "mipmapping": 0
});
# Later on change the mipmapping
myCanvas.mipmapping = 1;
Nia (you&, she/her)

Please use gender neutral terms when referring to a group of people!

Be the change you wish to see in the world, be an ally to all!

Join the official matrix space
merspieler
 
Posts: 2241
Joined: Thu Oct 26, 2017 11:43 am
Location: Wish to be in YBCS
Pronouns: you&, she/her
Callsign: you&, she/her
IRC name: merspieler
Version: next
OS: NixOS

Re: Changing canvas parameters after creation  

Postby Hooray » Sat Mar 13, 2021 8:50 am

try myCanvas.set("mipmapping",0) - keep in mind, the Canvas is a property driven subsystem, so you can browse to the corresponding location in the property tree and toggle the mipmapping property there.

For details:
cd $SG_SRC/canvas/
grep -nr mipmapping *.cxx

Code: Select all
Canvas.cxx:396:        _node->getBoolValue("mipmapping"),
Canvas.cxx:688:      else if(   name == "mipmapping"
ODGauge.cxx:11:// 2012 Supports now multisampling/mipmapping, usage of the stencil buffer and
ODGauge.cxx:179:  void ODGauge::setSampling( bool mipmapping,
ODGauge.cxx:183:    if(    !updateFlag(USE_MIPMAPPING, mipmapping)
ODGauge.cxx:255:      // otherwise OSG won't construct all the mipmaps for the texture
ODGauge.cxx:256:      // and dynamic mipmap generation doesn't work.



So, this can be done in C++ space (if sampling is dirty) or in fgdata space by using a workaround (2nd canvas) - however, the question remains whether that makes sense at all ? In other words, what is your use-case ? You are basically asking for the mipmaps to be discarded, which is probably heavier than using a separate canvas and an embedded canvas.image node - one with mipmaps enabled, the other disabled.
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: Changing canvas parameters after creation

Postby merspieler » Sat Mar 13, 2021 1:39 pm

Thanks.... Usecase: debugging... so don't worry about me doing that in production.
Nia (you&, she/her)

Please use gender neutral terms when referring to a group of people!

Be the change you wish to see in the world, be an ally to all!

Join the official matrix space
merspieler
 
Posts: 2241
Joined: Thu Oct 26, 2017 11:43 am
Location: Wish to be in YBCS
Pronouns: you&, she/her
Callsign: you&, she/her
IRC name: merspieler
Version: next
OS: NixOS


Return to Canvas

Who is online

Users browsing this forum: No registered users and 3 guests