<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">Hi,<br><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div><br>I mean that (as far as I understand from VTK source code) by design you cannot change the render window of a (at least) volume mapper because once the shader program is loaded and the context is setup by the following code:<br><br>...<br>if(this-&gt;Program==0)<br>&nbsp;{<br>&nbsp;&nbsp; 
this-&gt;Program=vtkShaderProgram2::New();<br>&nbsp;&nbsp; 
this-&gt;Program-&gt;SetContext(static_cast&lt;vtkOpenGLRenderWindow 
*&gt;(w));<br>&nbsp;}<br>...<br><br>the Program-&gt;SetContext is never called again because the object Program will be never destroyed (this-&gt;Program is always != 0) for the entire life of the mapper. So, I cannot reuse a mapper with (and only with) a new render window. This is a serious problem. There's no way to destroy the shader program inside the mapper?<br><br>P.S.: The gradients are computed on-the-fly? That's a really good thing, I haven't noticed this. So probably the slow initialization (few seconds is too much for my purposes) is due to volume upload in video memory card? (512x512x416 16 bit).<br><br></div><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><div style="font-family: arial,helvetica,sans-serif; font-size: 13px;"><font face="Tahoma" size="2"><hr size="1"><b><span style="font-weight: bold;">Da:</span></b> Francois Bertel &lt;francois.bertel@kitware.com&gt;<br><b><span style="font-weight: bold;">A:</span></b>
 vtk vtk &lt;vtkusers@vtk.org&gt;<br><b><span style="font-weight: bold;">Inviato:</span></b> Mer 16 giugno 2010, 16:51:44<br><b><span style="font-weight: bold;">Oggetto:</span></b> Re: [vtkusers] Reusing of vtkOpenGLGPUVolumeRayCastMapper...<br></font><br>A side note: you are talking about a very slow initialization due to<br>the gradients computation. But there is no gradient precomputation for<br>the vtkOpenGLGPUVolumeRayCastMapper. It is done on-the-fly during<br>rendering.<br><br>On Wed, Jun 16, 2010 at 10:48 AM, Francois Bertel<br>&lt;<a rel="nofollow" ymailto="mailto:francois.bertel@kitware.com" target="_blank" href="mailto:francois.bertel@kitware.com">francois.bertel@kitware.com</a>&gt; wrote:<br>&gt; Hello,<br>&gt;<br>&gt; Please post a minimal example to reproduce the problem.<br>&gt;<br>&gt; Regards.<br>&gt;<br>&gt; On Wed, Jun 16, 2010 at 6:01 AM, AGPX &lt;<a rel="nofollow" ymailto="mailto:agpxnet@yahoo.it" target="_blank"
 href="mailto:agpxnet@yahoo.it">agpxnet@yahoo.it</a>&gt; wrote:<br>&gt;&gt;
 Ok,<br>&gt;&gt;<br>&gt;&gt; it not the assert that fails. The variable Context is invalid, it still<br>&gt;&gt; point to the old destroyed object. This happen because we never change the<br>&gt;&gt; Context of the class vtkShaderProgram2 to the new render window. That is the<br>&gt;&gt; code:<br>&gt;&gt;<br>&gt;&gt; void vtkOpenGLGPUVolumeRayCastMapper::BuildProgram(vtkRenderWindow *w,<br>&gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int parallelProjection,<br>&gt;&gt;
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int raycastMethod,<br>&gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int shadeMethod,<br>&gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int
 componentMethod)<br>&gt;&gt; {<br>&gt;&gt;<br>&gt;&gt; &nbsp; assert("pre: valid_raycastMethod" &amp;&amp;<br>&gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; raycastMethod&gt;= vtkOpenGLGPUVolumeRayCastMapperMethodMIP<br>&gt;&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; raycastMethod&lt;=vtkOpenGLGPUVolumeRayCastMapperMethodAdditive);<br>&gt;&gt;<br>&gt;&gt; &nbsp; if(this-&gt;Program==0)<br>&gt;&gt; &nbsp;&nbsp;&nbsp; {<br>&gt;&gt; &nbsp;&nbsp;&nbsp; this-&gt;Program=vtkShaderProgram2::New();<br>&gt;&gt; &nbsp;&nbsp;&nbsp; this-&gt;Program-&gt;SetContext(static_cast&lt;vtkOpenGLRenderWindow *&gt;(w));<br>&gt;&gt; &nbsp;&nbsp;&nbsp; }<br>&gt;&gt; ...<br>&gt;&gt; }<br>&gt;&gt;<br>&gt;&gt; The Program variable isn't 0 and so the new context will never be setup. How<br>&gt;&gt; I can solve this?<br>&gt;&gt;<br>&gt;&gt; ________________________________<br>&gt;&gt; Da: AGPX &lt;<a rel="nofollow" ymailto="mailto:agpxnet@yahoo.it"
 target="_blank" href="mailto:agpxnet@yahoo.it">agpxnet@yahoo.it</a>&gt;<br>&gt;&gt; A: vtk vtk &lt;<a rel="nofollow" ymailto="mailto:vtkusers@vtk.org" target="_blank" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>&gt;<br>&gt;&gt; Inviato: Mer 16 giugno 2010, 10:40:35<br>&gt;&gt; Oggetto: [vtkusers] Reusing of vtkOpenGLGPUVolumeRayCastMapper...<br>&gt;&gt;<br>&gt;&gt; Hello,<br>&gt;&gt;<br>&gt;&gt; I have a vtkOpenGLGPUVolumeRayCastMapper that I have previously used with<br>&gt;&gt; another actor, renderer and render window. I wish to reuse it (creating a<br>&gt;&gt; new actor, renderer and renderwindow), but I obtain an assert error:<br>&gt;&gt;<br>&gt;&gt; //<br>&gt;&gt; ----------------------------------------------------------------------------<br>&gt;&gt; // Description:<br>&gt;&gt; // Use the shader program.<br>&gt;&gt; // It saves the current shader program or fixed-pipeline in use.<br>&gt;&gt; // It also set the uniform
 variables.<br>&gt;&gt; void vtkShaderProgram2::Use()<br>&gt;&gt;
 {<br>&gt;&gt; &nbsp; assert("pre: context_is_set" &amp;&amp; this-&gt;Context!=0);<br>&gt;&gt; &nbsp; assert("pre: current_context_matches" &amp;&amp; this-&gt;Context-&gt;IsCurrent());<br>&gt;&gt; &lt;---------------- Fail here!<br>&gt;&gt; &nbsp; this-&gt;Build();<br>&gt;&gt;<br>&gt;&gt; ....<br>&gt;&gt;<br>&gt;&gt; Look like that the context isn't current. There's a way to "reset" the<br>&gt;&gt; mapper internal state? Note that the volume data input is the same, so I<br>&gt;&gt; wish to reuse the mapper in order to avoid the very slow initialization<br>&gt;&gt; (especially the gradients computation). Any hints?<br>&gt;&gt;<br>&gt;&gt; Thanks in advance.<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br><span>&gt;&gt; Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a></span><br>&gt;&gt;<br>&gt;&gt; Visit other Kitware open-source projects at<br>&gt;&gt; <a
 rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br>&gt;&gt;<br>&gt;&gt; Please keep messages on-topic and check the VTK FAQ at:<br>&gt;&gt; <a rel="nofollow" target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt;&gt;<br>&gt;&gt; Follow this link to subscribe/unsubscribe:<br>&gt;&gt; <a rel="nofollow" target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;&gt;<br>&gt;&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>&gt; François Bertel, PhD &nbsp;| Kitware Inc. Suite 204<br>&gt; 1 (518) 371 3971 x113 | 28 Corporate Drive<br>&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;| Clifton Park NY 12065, USA<br>&gt;<br><br><br><br>-- <br>François Bertel, PhD&nbsp; | Kitware Inc. Suite 204<br>1 (518) 371 3971 x113 | 28 Corporate
 Drive<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | Clifton Park NY 12065, USA<br>_______________________________________________<br><span>Powered by <a rel="nofollow" target="_blank" href="http://www.kitware.com">www.kitware.com</a></span><br><br>Visit other Kitware open-source projects at <a rel="nofollow" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a rel="nofollow" target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></div></div>
</div><br>



      </div></div>
</div><br>



      </body></html>