[vtkusers] How create an offscreen render window in VTK ?? Please Help
Deepak Roy
cdeepakroy at yahoo.com
Wed Nov 30 20:05:18 EST 2005
Hello,
I tried vtkRenderWindow::OffScreenRenderingOn today but it does not work.
It would be really helpful if you could provide any examples.
I turned it on and used vtkWindowToImageFilter to save a snapshot of the OffScreenRenderWindow to an image file( JPEG ) on disk but the image comes out to be a snaphot of the desktop when the code is executed.
I am using the VTK + QT library written by Carsten Kibler. I suspect if that is giving the problem. Here is the link:
http://wwwipr.ira.uka.de/~kuebler/vtkqt/
Because My Application is developed with QT and VTK. So there is already a QT + VTK render window in which the model is being displayed. I am creating the offscreen render window after that, so i suspect there are some conflicts.Because if i turn the offscreenrendering to off ( which is the default ), the render window is not visible, which is not normally expected.
I am using offscreen rendering to find the volume enclosed between two surfaces.
--- First i render the surface behind ---> extract the z-buffer of the offscreen window.
---- Second i remove the surface behind and new render the front surface alone ---> extract the z-buffer again
----- Subtracting both the Z-buffers would give me the volume.
I earlier used vtkMassProperties but it does not give good results. Hence i resorted to the z-buffer technique.
Here is the code i used for the offscreen rendering:
************************************************************************************************
vtkOpenGLRenderer *pOffScreenRenderer = vtkOpenGLRenderer::New();
vtkRenderWindow *pOffScreenRenderWindow = vtkOpenGLRenderWindow::New();
pOffScreenRenderWindow->OffScreenRenderingOn();
pOffScreenRenderWindow->AddRenderer( pOffScreenRenderer );
pOffScreenRenderWindow->Start();
pOffScreenRenderWindow->SetSize( wx , wy );
pOffScreenRenderWindow->Render();
// render a surface now
pOffScreenRenderer->AddActor( pSurfaceActor );
pOffScreenRenderer->Render();
pOffScreenRenderWindow->Render();
// save a snapshot to disk
vtkWindowToImageFilter *pWindowImageFilter = vtkWindowToImageFilter::New();
pWindowImageFilter->SetInput( pOffScreenRenderWindow );
vtkJPEGWriter *pImageWriter = vtkJPEGWriter::New();
pImageWriter->SetInput( pWindowImageFilter->GetOutput() );
pImageWriter->SetQuality( 100 );
pImageWriter->SetFileName( "coons_image.jpg" );
pImageWriter->ProgressiveOff();
pImageWriter->Write();
pImageWriter->Delete();
*************************************************************************************************
Is there anything wrong with the code ?
Please Help !!!!!
Thanks in Advance.
Regards
Deepak Roy
Sylvain Jaume <sylvain.jaume at kitware.com> wrote:
Hi Deepak,
Have you tried vtkRenderWindow::OffScreenRenderingOn?
http://www.vtk.org/doc/nightly/html/classvtkWindow.html#803e4f1aba85b796a0f17b0ec84093f9
Cheers,
Sylvain
Deepak Roy wrote:
> hello everybody,
>
> Do you know how to create an offscreen vtk render window in VTK ?
>
> I want to render into the off screen render window and then get its
> z-buffer using GetZbufferData
>
> () and work on its z-buffer.
>
> Or is there an offscreen buffer similar to vtkRenderWindow.
>
> Please Help.
>
> Thanks in advance.
>
> Regards,
>
> Deepak
>
> ------------------------------------------------------------------------
> Yahoo! DSL
>
> Something to write home about. Just $16.99/mo. or less
>
>------------------------------------------------------------------------
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>
---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
---------------------------------
Yahoo! Music Unlimited - Access over 1 million songs. Try it free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20051130/374ff3f1/attachment.htm>
More information about the vtkusers
mailing list