Hi Sebastien,<div><br></div><div>thanks for your answer. I have checked vtkPanel. But it seems to be a heavyweight AWT component. Java 7 is currently no option for me and I need real transparency etc. There is no easy way to access the pixel data from Java and it seems like vtkPanel only works if it is atached to a JFrame. Is that correct?<div>

<br></div><div>I chose to create an alternative implementation. I uploaded it to GitHub: <a href="http://miho.github.com/JVTK/">http://miho.github.com/JVTK/</a></div><div><br></div><div>The project contains a pure lightweight Swing panel that uses a vtkPanel internally. The panel converts the native pixel data to an AWT image that is used to paint the Swing panel. I implemented basic fullscreen support. In fullscreen mode the internal vtkPanel is used. This allows full render performance.</div>

<div><br></div><div>The project contains a sample application that demonstrates its features.</div><div><br></div><div>It would be nice if you could check my implementation. Maybe there is a better way to convert pixeldata...</div>

<div><br></div><div>Regards,</div><div>Michael</div></div><br><div class="gmail_quote">2012/5/28 Sebastien Jourdain <span dir="ltr">&lt;<a href="mailto:sebastien.jourdain@kitware.com" target="_blank">sebastien.jourdain@kitware.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think you have a better solution on your end since you are using Java.<br>
The idea is to use a vtkPanel or vtkCanvas directly without inserting<br>
it in a graphical component. Somehow, it will be offscreen and you<br>
will keep the GPU acceleration.<br>
<br>
Let me know how it goes.<br>
<br>
Seb<br>
<div><div class="h5"><br>
On Sun, May 27, 2012 at 3:48 PM, Michael Hoffer &lt;<a href="mailto:info@michaelhoffer.de">info@michaelhoffer.de</a>&gt; wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; i am totally new to VTK. First of all, I was really surprised how easy it is<br>
&gt; to setup VTK with Java. I compiled it on Linux and OS X. Well done!<br>
&gt;<br>
&gt; Now my question: as I am interested in offscreen rendering I tried the<br>
&gt; example below. It worked but unfortunately an empty window was shown. I<br>
&gt; didn&#39;t expect a window. Do I really have to completely switch hardware<br>
&gt; acceleration off by using VTK_OPENGL_HAS_OSMESA? Couldn&#39;t I just hide the<br>
&gt; window? If it is possible, how do I do that?<br>
&gt;<br>
&gt; My intention is to write a pure Swing component that uses offscreen<br>
&gt; rendering. I know that this will slow down everything. But my views will be<br>
&gt; relatively small in size (e.g. 300x200 pixel). Thus, the performance should<br>
&gt; be ok as long as getting the native memory isn&#39;t too time consuming. I have<br>
&gt; seen that there are some approaches that also tried that. But all code<br>
&gt; samples I have seen looped over the vtk array to copy it to an image. This<br>
&gt; is definitely too slow. But using WritableRaster, DataBuffer etc. should<br>
&gt; help.<br>
&gt;<br>
&gt; Thanks for your help!<br>
&gt;<br>
&gt; Regards,<br>
&gt; Michael<br>
&gt;<br>
&gt; //<br>
&gt; // code originally<br>
&gt; from <a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering</a><br>
&gt; //<br>
&gt; import vtk.*;<br>
&gt;<br>
&gt; /**<br>
&gt;  *<br>
&gt;  * @author Michael Hoffer <a href="mailto:info@michaelhoffer.de">info@michaelhoffer.de</a><br>
&gt;  */<br>
&gt; public class VTKOffscreenSample {<br>
&gt;<br>
&gt;     public static void main(String[] args) {<br>
&gt;<br>
&gt;         loadLibraries();<br>
&gt;<br>
&gt;         // Setup offscreen rendering<br>
&gt;         vtkGraphicsFactory graphics_factory = new vtkGraphicsFactory();<br>
&gt;         graphics_factory.SetOffScreenOnlyMode(1);<br>
&gt;         graphics_factory.SetUseMesaClasses(1);<br>
&gt;<br>
&gt;         vtkImagingFactory imaging_factory = new vtkImagingFactory();<br>
&gt;         imaging_factory.SetUseMesaClasses(1);<br>
&gt;<br>
&gt;         // Create a sphere<br>
&gt;         vtkSphereSource sphereSource = new vtkSphereSource();<br>
&gt;<br>
&gt;         // Create a mapper and actor<br>
&gt;         vtkPolyDataMapper mapper = new vtkPolyDataMapper();<br>
&gt;         mapper.SetInputConnection(sphereSource.GetOutputPort());<br>
&gt;<br>
&gt;         vtkActor actor = new vtkActor();<br>
&gt;         actor.SetMapper(mapper);<br>
&gt;<br>
&gt;         // A renderer and render window<br>
&gt;         vtkRenderer renderer = new vtkRenderer();<br>
&gt;         vtkRenderWindow renderWindow = new vtkRenderWindow();<br>
&gt;         renderWindow.SetOffScreenRendering(1);<br>
&gt;         renderWindow.AddRenderer(renderer);<br>
&gt;<br>
&gt;         // Add the actors to the scene<br>
&gt;         renderer.AddActor(actor);<br>
&gt;         renderer.SetBackground(1, 1, 1); // Background color white<br>
&gt;<br>
&gt;         renderWindow.Render();<br>
&gt;<br>
&gt;         vtkWindowToImageFilter windowToImageFilter = new<br>
&gt; vtkWindowToImageFilter();<br>
&gt;         windowToImageFilter.SetInput(renderWindow);<br>
&gt;         windowToImageFilter.Update();<br>
&gt;<br>
&gt;         vtkPNGWriter writer = new vtkPNGWriter();<br>
&gt;         writer.SetFileName(&quot;screenshot.png&quot;);<br>
&gt;         writer.SetInputConnection(windowToImageFilter.GetOutputPort());<br>
&gt;         writer.Write();<br>
&gt;     }<br>
&gt;<br>
&gt;     private static void loadLibraries() {<br>
&gt;<br>
&gt;         if (!vtkNativeLibrary.LoadAllNativeLibraries()) {<br>
&gt;             for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {<br>
&gt;                 if (!lib.IsLoaded()) {<br>
&gt;                     System.out.println(lib.GetLibraryName() + &quot; not<br>
&gt; loaded&quot;);<br>
&gt;                 }<br>
&gt;             }<br>
&gt;<br>
&gt;             System.out.println(&quot;Make sure the search path is correct: &quot;);<br>
&gt;             System.out.println(System.getProperty(&quot;java.library.path&quot;));<br>
&gt;         }<br>
&gt;<br>
&gt;         vtkNativeLibrary.DisableOutputWindow(null);<br>
&gt;     }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the VTK FAQ at:<br>
&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
&gt;<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Dipl.-Math. Michael Hoffer<br><br>Goethe-Zentrum für Wissenschaftliches Rechnen (G-CSC)<br>Goethe-Universität<br>Kettenhofweg 139<br>60325 Frankfurt am Main<br>

Tel.: +49 69 798 25254<br><a href="mailto:michael.hoffer@gcsc.uni-frankfurt.de" target="_blank">michael.hoffer@gcsc.uni-frankfurt.de</a><br>