[vtkusers] EGL offscreen rendering

Scott Wittenburg scott.wittenburg at kitware.com
Wed Dec 13 17:11:43 EST 2017


I like to just save a screenshot for that purpose.  Following is some
sample code (I did not run this exactly, so you may need to tweak it, add
includes, etc...)

*Python*

from vtk import *

source = vtkConeSource()

mapper = vtkPolyDataMapper()
mapper.SetInputConnection(source.GetOutputPort())

actor = vtkActor()
actor.SetMapper(mapper)

ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
ren.AddActor(actor)
renWin.Render()

w2if = vtkWindowToImageFilter()
w2if.SetInput(renWin)
w2if.ReadFrontBufferOff()
writer = vtkPNGWriter()
writer.SetInputConnection(w2if.GetOutputPort())
w2if.Update()
writer.SetFileName('/tmp/savedConeImage.png')
writer.Write()

*C++*

vtkSmartPointer<vtkConeSource> source =
vtkSmartPointer<vtkConeSource>::New();

vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(source->GetOutputPort());

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

vtkSmartPointer<vtkRenderer> ren = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renWin =
vtkSmartPointer<vtkRenderWindow>::New();
renWin->AddRenderer(ren);
ren->AddActor(actor);
renWin->Render();

vtkSmartPointer<vtkWindowToImageFilter> w2if =
vtkSmartPointer<vtkWindowToImageFilter>::New();
w2if->SetInput(renWin);
w2if->ReadFrontBufferOff();

vtkSmartPointer<vtkPNGWriter> writer = vtkSmartPointer<vtkPNGWriter>::New();
writer->SetInputConnection(w2if->GetOutputPort());
w2if->Update();

writer->SetFileName("/tmp/savedConeImage.png");
writer->Write();


Hope that helps.

Cheers,
Scott



On Wed, Dec 13, 2017 at 3:01 PM, Elhassan Abdou <elhassan.abdou at gmail.com>
wrote:

> Hi
>
>
>
> Can you suggest a way to debug my output from the offscreen rendering
> process ?
>
>
>
> I appreciate your help
>
> Elhassan
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *Utkarsh Ayachit <utkarsh.ayachit at kitware.com>
> *Sent: *Wednesday, December 13, 2017 3:58 PM
> *To: *Elhassan Abdou <elhassan.abdou at gmail.com>
> *Cc: *vtk <vtkusers at vtk.org>
> *Subject: *Re: [vtkusers] EGL offscreen rendering
>
>
>
> Elhassan,
>
>
>
> For VTK 8.1, you can set the following CMake variables:
>
>
>
> VTK_USE_X=OFF
>
> VTK_OPENGL_HAS_EGL=ON
>
> EGL_INCLUDE_DIR: Path to directory containing GL/egl.h.
>
> EGL_LIBRARY: Path to libEGL.so.
>
> EGL_opengl_LIBRARY: Path to libOpenGL.so.
>
>
>
> > How can I visually debug the output of the EGL rendering?
>
>
>
> Currently, we don't support an on-screen rendering with EGL.
>
>
>
> Utkarsh
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20171213/b0740715/attachment.html>


More information about the vtkusers mailing list