No announcement yet.

Usage of SoRenderToTarget by applying a SoGLRenderAction?

  • Filter
  • Time
  • Show
Clear All
new posts

  • Usage of SoRenderToTarget by applying a SoGLRenderAction?

    Has anybody a code example for the usage of a SoRenderToTarget Node separate from the main scene graph by applying a SoGLRenderAction? I only found examples for a SoRenderToTarget added as SoSparator directly into the main scene graph.

  • #2
    Yes, SoRenderToTarget can be used separate from the main scene graph.
    I have attached an example program:

    This program is essentially the same as SimpleRenderToTarget example except -- In the original version the SoRenderToTarget node is part of the main scene graph and is traversed using the main scene's camera, light, etc. But in this version, the SoRenderToTarget node is a separate scene graph that is only traversed "on request" using an SoGLRenderAction. You could easily arrange for the separate scene graph to be automatically re-rendered using an Open Inventor sensor class.

    This requires a little more code than the original version because the RenderToTarget scene graph will not inherit the Open Inventor state (camera, light, renderAction) and the OpenGL state (GLContext, depth buffer test, etc) that are automatically setup by the viewer in the original version.

    Expected behavior:
    1. Initial window
    Should see: The image of a RED sphere textured onto all sides of a cube.
    2. Click the "Change Color" button
    Should see: No change (separate scene graph has not been rendered yet).
    3. Click the "Re-render" button
    Should see: The image of a YELLOW sphere textured on the cube.
    4. Click "Change Color", then click "Re-render"
    Should see: Image of a RED sphere again