Canvas view camera element: Difference between revisions
Jump to navigation
Jump to search
(→C++) |
|||
Line 2: | Line 2: | ||
== C++ == | == C++ == | ||
The following is the boilerplate code neede to add a new element to the Canvas system inheriting from the Canvas::Image class, i.e. an element having its own allocated Image/texture buffer, which is what we can use to render a camera into it: | |||
<syntaxhighlight lang="diff"> | <syntaxhighlight lang="diff"> | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 10:05, 27 August 2017
This article is a stub. You can help the wiki by expanding it. |
C++
The following is the boilerplate code neede to add a new element to the Canvas system inheriting from the Canvas::Image class, i.e. an element having its own allocated Image/texture buffer, which is what we can use to render a camera into it:
Base Package
Nasal Console
After patching and rebuilding SimGear/FlightGear respectively, and applying the changes to to api.nas in the base package, the following can be pasted into the Nasal Console for testing purposes:
var ELEMENT_NAME ="view-camera"; # to be adapted according to the C++ changes
var myElementTest = {
##
# constructor
new: func(view=0, width=640,height=480) {
var m = { parents: [myElementTest] };
m.dlg = canvas.Window.new([width,height],"dialog");
m.canvas = m.dlg.createCanvas().setColorBackground(1,1,1,1);
m.root = m.canvas.createGroup();
##
# instantiate a new element
m.myElement = m.root.createChild( ELEMENT_NAME );
m.init();
return m;
}, # new
}; # end of myElementTest
var cameras = [
{view: 0, width : 640, height: 480},
{view: 1, width : 640, height: 480},
{view: 2, width : 640, height: 480},
];
foreach(var cam; camers) {
var newCam = myElementTest.new( view: cam.view, width: cam.width, height: cam.height );
}
Related
References
|