20,741
edits
| Line 257: | Line 257: | ||
=== Serializing a Canvas to disk (as raster image) === | === Serializing a Canvas to disk (as raster image) === | ||
In OSG land, the following C++ code can be used to easily serialize a Canvas to disk - this can be useful for making bug reports, without having to take/edit a full screen shot, it's based on the existing screen shot code that's been slightly adapted: | |||
<syntaxhighlight lang="cpp"> | |||
osg::Image* shot = new osg::Image(); | |||
shot->allocateImage(width, height, 24, GL_RGB, GL_UNSIGNED_BYTE); | |||
camera->attach(osg::Camera::COLOR_BUFFER, shot); | |||
osgDB::writeImageFile(*shot,"canvasImage.png"); | |||
</syntaxhighlight> | |||
Adapting this to render a Canvas to an image, and expose the whole thing via cppbind, gets us here: | |||
<syntaxhighlight lang="diff"> | |||
</syntaxhighlight> | |||
And here are the corresponding changes for $FG_SRC: | |||
<syntaxhighlight lang="diff"> | <syntaxhighlight lang="diff"> | ||
</syntaxhighlight> | </syntaxhighlight> | ||