#include <SoFCOffscreenRenderer.h>
Public Member Functions | |
const SbColor4f & | getBackgroundColor (void) const |
SoGLRenderAction * | getGLRenderAction (void) const |
int | getNumPasses (void) const |
const SbViewportRegion & | getViewportRegion (void) const |
QStringList | getWriteImageFiletypeInfo () const |
GLenum | internalTextureFormat () const |
SbBool | render (SoNode *scene) |
SbBool | render (SoPath *scene) |
void | setBackgroundColor (const SbColor4f &color) |
void | setGLRenderAction (SoGLRenderAction *action) |
void | setInternalTextureFormat (GLenum internalTextureFormat) |
void | setNumPasses (const int num) |
void | setViewportRegion (const SbViewportRegion ®ion) |
SoQtOffscreenRenderer (const SbViewportRegion &viewportregion) | |
SoQtOffscreenRenderer (SoGLRenderAction *action) | |
void | writeToImage (QImage &) const |
~SoQtOffscreenRenderer () | |
SoQtOffscreenRenderer::SoQtOffscreenRenderer | ( | const SbViewportRegion & | viewportregion | ) |
Constructor. Argument is the viewportregion we should use when rendering. An internal SoGLRenderAction will be constructed.
SoQtOffscreenRenderer::SoQtOffscreenRenderer | ( | SoGLRenderAction * | action | ) |
Constructor. Argument is the action we should apply to the scene graph when rendering the scene. Information about the viewport is extracted from the action.
SoQtOffscreenRenderer::~SoQtOffscreenRenderer | ( | ) |
Destructor.
const SbColor4f & SoQtOffscreenRenderer::getBackgroundColor | ( | void | ) | const |
Returns the background color.
Referenced by Gui::SoQtOffscreenRendererPy::getBackgroundColor().
SoGLRenderAction * SoQtOffscreenRenderer::getGLRenderAction | ( | void | ) | const |
Returns the rendering action currently used.
int SoQtOffscreenRenderer::getNumPasses | ( | void | ) | const |
Referenced by Gui::SoQtOffscreenRendererPy::getNumPasses().
const SbViewportRegion & SoQtOffscreenRenderer::getViewportRegion | ( | void | ) | const |
Returns the viewerport region.
Referenced by Gui::SoQtOffscreenRendererPy::getViewportRegion().
QStringList SoQtOffscreenRenderer::getWriteImageFiletypeInfo | ( | ) | const |
This method returns all image file formats supported by Coin3D (see getWriteFiletypeInfo()) with all QImage file formats that are not directly supported by Coin3D, if so.
Referenced by StdViewScreenShot::activated(), and Gui::SoQtOffscreenRendererPy::getWriteImageFiletypeInfo().
GLenum SoQtOffscreenRenderer::internalTextureFormat | ( | ) | const |
Referenced by Gui::SoQtOffscreenRendererPy::getInternalTextureFormat(), and setInternalTextureFormat().
SbBool SoQtOffscreenRenderer::render | ( | SoNode * | scene | ) |
Render the scenegraph rooted at scene into our internal pixel buffer.
Important note: make sure you pass in a scene node pointer which has both a camera and at least one lightsource below it – otherwise you are likely to end up with just a blank or black image buffer.
This mistake is easily made if you use an SoQtOffscreenRenderer on a scenegraph from one of the standard viewer components, as you will often just leave the addition of a camera and a headlight lightsource to the viewer to set up. This camera and lightsource are then part of the viewer's private "super-graph" outside of the scope of the scenegraph passed in by the application programmer. To make sure the complete scenegraph (including the viewer's "private parts" (snicker)) are passed to this method, you can get the scenegraph root from the viewer's internal SoSceneManager instance instead of from the viewer's own getSceneGraph() method, like this:
If you do this and still get a blank buffer, another common problem is to have a camera which is not actually pointing at the scene geometry you want a snapshot of. If you suspect that could be the cause of problems on your end, take a look at SoCamera::pointAt() and SoCamera::viewAll() to see how you can make a camera node guaranteed to be directed at the scene geometry.
Yet another common mistake when setting up the camera is to specify values for the SoCamera::nearDistance and SoCamera::farDistance fields which doesn't not enclose the full scene. This will result in either just the background color, or that parts at the front or the back of the scene will not be visible in the rendering.
Referenced by MeshGui::ViewProviderMesh::getVisibleFacets(), Gui::SoQtOffscreenRendererPy::render(), and Gui::View3DInventorViewer::savePicture().
SbBool SoQtOffscreenRenderer::render | ( | SoPath * | scene | ) |
Render the scene path into our internal memory buffer.
void SoQtOffscreenRenderer::setBackgroundColor | ( | const SbColor4f & | color | ) |
Sets the background color. The buffer is cleared to this color before rendering.
Referenced by MeshGui::ViewProviderMesh::getVisibleFacets(), Gui::View3DInventorViewer::savePicture(), and Gui::SoQtOffscreenRendererPy::setBackgroundColor().
void SoQtOffscreenRenderer::setGLRenderAction | ( | SoGLRenderAction * | action | ) |
Sets the render action. Use this if you have special rendering needs.
void SoQtOffscreenRenderer::setInternalTextureFormat | ( | GLenum | internalTextureFormat | ) |
References internalTextureFormat().
Referenced by Gui::View3DInventorViewer::savePicture(), and Gui::SoQtOffscreenRendererPy::setInternalTextureFormat().
void SoQtOffscreenRenderer::setNumPasses | ( | const int | num | ) |
Referenced by Gui::View3DInventorViewer::savePicture(), and Gui::SoQtOffscreenRendererPy::setNumPasses().
void SoQtOffscreenRenderer::setViewportRegion | ( | const SbViewportRegion & | region | ) |
Sets the viewport region.
This will invalidate the current buffer, if any. The buffer will not contain valid data until another call to SoOffscreenRendererQt::render() happens.
Referenced by Gui::SoQtOffscreenRendererPy::setViewportRegion().
void SoQtOffscreenRenderer::writeToImage | ( | QImage & | img | ) | const |
Writes the rendered image buffer directly into a QImage object.
Referenced by MeshGui::ViewProviderMesh::getVisibleFacets(), Gui::View3DInventorViewer::savePicture(), and Gui::SoQtOffscreenRendererPy::writeToImage().