<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all.<br>
<br>
Is it possible to redirect the main camera of a view temporarily to
a FBO?<br>
It is my intention to get a snapshot of the scene with a modified
projection matrix.<br>
I think about something like that:<br>
<br>
<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>> camera =
view->getCamera();<br>
osg::Camera::RenderTargetImplementation rti =
camera->getRenderTargetImplementation();<br>
<span style=" color:#c0c0c0;"> </span><span style=" color:#800080;">osg</span>::<span
style=" color:#800080;">Matrixd</span><span style="
color:#c0c0c0;"> </span>projectionMatrix<span style="
color:#c0c0c0;"> </span>=<span style=" color:#c0c0c0;"> </span><span
style=" color:#800000;">view</span>->getCamera()->getProjectionMatrix();
<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>
camera->setRenderTargetImplementation(<span style="
color:#800080;">osg</span>::<span style=" color:#800080;">Camera</span>::<span
style=" color:#800080;">FRAME_BUFFER_OBJECT</span>);
<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>
<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;">Image>
</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 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=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">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>);</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;">camera->setProjectionMatrix(<span style=" color:#c0c0c0;"> </span>projectionMatrix<span style=" color:#c0c0c0;"> </span>*<span style=" color:#c0c0c0;"> </span>offsetMatrix<span style=" color:#c0c0c0;"> </span>);
</pre>
<span style=" color:#c0c0c0;"> </span><span style=" color:#800000;">view</span>-><span
style=" font-style:italic; color:#000000;">frame</span>();<br>
<br>
camera->setRenderTargetImplementation(<span style="
color:#800080;">rti</span>);<br>
camera->detach(<span style=" color:#800080;"> osg</span>::<span
style=" color:#800080;">Camera</span>::<span style="
color:#800080;">COLOR_BUFFER</span>
);<br>
<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;">camera->setProjectionMatrix(<span style=" color:#c0c0c0;"> </span>projectionMatrix<span style=" color:#c0c0c0;"> </span>);
</pre>
I tried it but my screen gets updated on the frame() call with the
modified projection matrix <br>
and the image stays black.<br>
<br>
Thanks for any hints.<br>
<br>
- Werner -<br>
<div class="moz-signature"><br>
</div>
</body>
</html>