Canvas development: Difference between revisions

Jump to navigation Jump to search
m
Line 1,375: Line 1,375:
* using Canvas textures in effects (i.e. registered as materials via a corresponding new 'materials placement')
* using Canvas textures in effects (i.e. registered as materials via a corresponding new 'materials placement')
}}
}}
In mid 2016, a number of contributors discussed another workaround to use Canvas textures in conjunction with effects/shaders: simply, by allowing an arbitrary Canvas to be registered as a '''material''' via SGMaterialLib, e.g. using an API in the form of <code>myCanvas.registerMaterial(name: "myCanvasMaterial");</code>
Equally, materials would make it possible to easily use arbitrary effects and shaders per Canvas element:
<syntaxhighlight lang="cpp">
Effect *effect = 0;
SGMaterialCache* matcache = matlib->generateMatCache(b.get_center());
SGMaterial* mat = matcache->find( "myCanvasMaterial" );
delete matcache;
if ( mat != NULL ) {
        // set OSG State
        effect = mat->get_effect();
    } else {
        SG_LOG( SG_TERRAIN, SG_ALERT, "Ack! unknown use material name = myCanvasMaterial");
    }
</syntaxhighlight>


{{FGCquote
{{FGCquote

Navigation menu