<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi all.<br>
    <br>
    I have a problem understanding how cameras handle render targets.<br>
    My special case:<br>
    I have a standard camera on a view.<br>
    The root node of the scene is a group with the following children:<br>
    <br>
    - my model<br>
    - hud camera for wallpaper<br>
    - hud camera for text<br>
    - more cameras for special cases<br>
    <br>
    All the cameras are children of the group node and do <span style="
      color:#008000;">POST_RENDER </span>operation.<br>
    <br>
    I need snapshots of the complete scene from various camera
    positions.<br>
    What I do:<br>
    <br>
    <span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span
      style=" color:#800080;">ref_ptr</span><<span style="
      color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>><span
      style=" color:#c0c0c0;"> </span>camera<span style="
      color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span
      style=" color:#800000;">view</span>->getCamera();
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">ref_ptr</span><<span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Image</span>><span style=" color:#c0c0c0;"> </span>fbImage<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span style=" color:#808000;">new</span><span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Image</span>;</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">fbImage-><span style=" font-style:italic; color:#000000;">allocateImage</span>(width,height,<span style=" color:#000080;">1</span>,<span style=" color:#000080;">GL_RGBA</span>,<span style=" color:#000080;">GL_UNSIGNED_BYTE</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">1</span>);

</pre>
    <pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>::<span style=" color:#800080;">RenderTargetImplementation</span><span style=" color:#c0c0c0;"> </span>rti<span style=" color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span>camera->getRenderTargetImplementation();
camera->setRenderTargetImplementation(<span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>::<span style=" color:#800080;">FRAME_BUFFER_OBJECT</span>);
camera->attach(<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>::<span style=" color:#800080;">COLOR_BUFFER</span>,<span style=" color:#c0c0c0;"> </span>fbImage.get(),<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>,<span style=" color:#c0c0c0;"> </span><span style=" color:#000080;">0</span>);
camera->dirtyAttachmentMap();

</pre>
    Then I do snapshots with the modified projection matrix of the
    camera.<br>
    After each snapshot I read the contents of the fbImage.<br>
    <br>
    I reset everything to the initial status by:<br>
    <span style=" color:#c0c0c0;"> </span><br>
    camera->setRenderTargetImplementation(rti);
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">camera->detach(<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>::<span style=" color:#800080;">COLOR_BUFFER</span>);</pre>
    <pre style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">camera->dirtyAttachmentMap();</pre>
    <pre style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">
</pre>
    <br>
    Unfortunately the fbImage always only contains my model but not the
    child cameras renderings.<br>
    Attaching the fbImage to the child cameras as well gives me just a
    black fbImage.<br>
    Of course the child cameras do not clear the color buffer.<br>
    <br>
    What is the proper way of receiving the complete rendering? I also
    tried already <br>
    installing a slave camera to the main camera but that also gives me
    only the rendered model.<br>
    And rendering to the fbImage by installing an additional child
    camera with <span style=" color:#008000;">POST_RENDER </span>instead
    <br>
    of a slave camera leads to the same result.<br>
    <br>
    Rendering to screen is perfect, but to fbImage is not.<br>
    It seems I'm blind on some basic functionality and all my research
    doesn't open my eyes.<br>
    <br>
    I instantly hope for some help.<br>
    <br>
    Thanks<br>
    <br>
    - Werner -<br>
  </body>
</html>