Gui::SoQtOffscreenRenderer Class Reference

#include <SoFCOffscreenRenderer.h>

Public Member Functions

const SbColor4f & getBackgroundColor (void) const
 
SoGLRenderActiongetGLRenderAction (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 &region)
 
 SoQtOffscreenRenderer (const SbViewportRegion &viewportregion)
 
 SoQtOffscreenRenderer (SoGLRenderAction *action)
 
void writeToImage (QImage &) const
 
 ~SoQtOffscreenRenderer ()
 

Constructor & Destructor Documentation

◆ SoQtOffscreenRenderer() [1/2]

SoQtOffscreenRenderer::SoQtOffscreenRenderer ( const SbViewportRegion &  viewportregion)

Constructor. Argument is the viewportregion we should use when rendering. An internal SoGLRenderAction will be constructed.

◆ SoQtOffscreenRenderer() [2/2]

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::~SoQtOffscreenRenderer ( )

Destructor.

Member Function Documentation

◆ getBackgroundColor()

const SbColor4f & SoQtOffscreenRenderer::getBackgroundColor ( void  ) const

Returns the background color.

Referenced by Gui::SoQtOffscreenRendererPy::getBackgroundColor().

◆ getGLRenderAction()

SoGLRenderAction * SoQtOffscreenRenderer::getGLRenderAction ( void  ) const

Returns the rendering action currently used.

◆ getNumPasses()

int SoQtOffscreenRenderer::getNumPasses ( void  ) const

◆ getViewportRegion()

const SbViewportRegion & SoQtOffscreenRenderer::getViewportRegion ( void  ) const

Returns the viewerport region.

Referenced by Gui::SoQtOffscreenRendererPy::getViewportRegion().

◆ getWriteImageFiletypeInfo()

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().

◆ internalTextureFormat()

GLenum SoQtOffscreenRenderer::internalTextureFormat ( ) const

◆ render() [1/2]

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:

SoQtOffscreenRenderer * myRenderer = new SoQtOffscreenRenderer(vpregion);
SoNode * root = myViewer->getSceneManager()->getSceneGraph();
SbBool ok = myRenderer->render(root);
// [then use image buffer in a texture, or write it to file, or whatever]

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.

See also
writeToImage()

Referenced by MeshGui::ViewProviderMesh::getVisibleFacets(), Gui::SoQtOffscreenRendererPy::render(), and Gui::View3DInventorViewer::savePicture().

◆ render() [2/2]

SbBool SoQtOffscreenRenderer::render ( SoPath *  scene)

Render the scene path into our internal memory buffer.

◆ setBackgroundColor()

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().

◆ setGLRenderAction()

void SoQtOffscreenRenderer::setGLRenderAction ( SoGLRenderAction action)

Sets the render action. Use this if you have special rendering needs.

◆ setInternalTextureFormat()

void SoQtOffscreenRenderer::setInternalTextureFormat ( GLenum  internalTextureFormat)

◆ setNumPasses()

void SoQtOffscreenRenderer::setNumPasses ( const int  num)

◆ setViewportRegion()

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().

◆ writeToImage()

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().


The documentation for this class was generated from the following files: