Board index FlightGear Development Canvas

One suggestion: FlightGear wolud support plugins like this!

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.

One suggestion: FlightGear wolud support plugins like this!

Postby CHIV » Thu May 08, 2014 9:03 am

I want draw something in the front face of the FlightGear view, but I don't wan to recompile / modify any codes, so, if the FlightGear could give me a interface
to draw something myself through DLL, that's perfect.

Only 3 functions in my DLL.

bool Initialize(void **user_data);
void Update(int view_id);
void Exit(void **usr_data);

this function will be called every frame. Before calling this function, the FlightGear must push it's context, then pop it after calling. I will draw on the FlightGear's
opengl-context.

my example:
bool Initialize(void **user_data)
{
try {
myResource *rc = new myResource("rc.cfg");
*user_data = rc;
return true;
}
catch (Exception &e) {
e.Raise();
return false;
}
}
void Update(int view_id)
{
if (view_id != MY_CHANNEL) return ;
if (!glew_initialized) { myGLEW_init(); }
else {
draw_user_myResource();
}
}

void Exit(void **usr)
{
if (*usr) {
myResource *rc = (myResource *)(*usr);
delete rc;
}
}

desc: myResource is a WarpUnit which will generate a warped surface-defined by some 2D Points, i will read the framebuffer, treat is as one texture. So,
I can project the FlightGear to sphere / cylinder surface.

My suggestion is not so good, may be improved here.Could I get one copy on the next release?
CHIV
 
Posts: 4
Joined: Thu May 08, 2014 8:25 am

Re: One suggestion: FlightGear wolud support plugins like th

Postby Hooray » Thu May 08, 2014 9:46 am

Hi & welcome,

thanks for taking the time to make a feature request.

I want draw something in the front face of the FlightGear view, but I don't wan to recompile / modify any codes, so, if the FlightGear could give me a interface
to draw something myself through DLL, that's perfect.

Regarding binary plugins (DLLs/DSOs) the general consensus among developers is that FlightGear, being open source, doesn't need -and shouldn't support- binary plugins. You will find additional information at: http://wiki.flightgear.org/Nasal_for_C% ... on_plugins

However, FlightGear being based on osgViewer/OSG, it is obviously using some OSG plugins already.

In general, FlightGear supports an integrated scripting language (like JavaScript) called "Nasal": http://wiki.flightgear.org/Nasal
as well as a 2D rendering API called "Canvas", analogous to HTML5 Canvas, just hardware-accelerated using OSG/OpenGL: http://wiki.flightgear.org/Canvas

The combination of Nasal/Canvas allows arbitary 2D stuff to be drawn, including HUDs, glass cockpit stuff, scenery features (VDGS) and even our GUI is based on Nasal/Canvas.
None of this requires recompiling/rebuilding any of FlightGear's components. For example, the following screen shots shows two displays (PFD & ND) that are fully scripted:
Image

The whole thing also works without Nasal, it's all based on the property tree: http://wiki.flightgear.org/Property_Tree
So you could even use a conventional telnet connection: http://wiki.flightgear.org/Telnet_usage

I will draw on the FlightGear's
opengl-context.

http://wiki.flightgear.org/Canvas_HUD
Image

If you find that our Canvas system is missing any features, you'll probably want to extend it instead: http://wiki.flightgear.org/Canvas_Development

myResource is a WarpUnit which will generate a warped surface-defined by some 2D Points, i will read the framebuffer, treat is as one texture. So,
I can project the FlightGear to sphere / cylinder surface.

If you are interested in doing this for modifying camera views, you'll want to check out the window/camera view subsystem, which isn't currently exposed to Nasal/Canvas, but still very configurable:

http://wiki.flightgear.org/FlightGear_N ... ed_display


For image processing purposes like OpenCV, it would make sense to look at: http://wiki.flightgear.org/Canvas_Devel ... ter_Vision#

Also, you could probably use a combination of effects and shaders to created a warped image to some degree: http://wiki.flightgear.org/Howto:Shader ... FlightGear

My suggestion is not so good, may be improved here.Could I get one copy on the next release?


Sorry, not sure what you're asking 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: 11968
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 1 guest