[vtkusers] Combined on-screen and off-screen possible with VTK-7.0.0 on linux/X?

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Oct 28 09:52:02 EDT 2016


2016-10-28 15:49 GMT+02:00 Ken Martin <ken.martin at kitware.com>:
> I believe you can use
>
>   renderWindow->OffScreenRenderingOn();
>   renderWindow->Render();
>   renderWindow->OffScreenRenderingOff();
>   renderWindow->Render();
>
> to swap between on/offscreen. There is a new test TestToggleOSWithInteractor
> that checks for this. As a warning that test works on OpenGL2 with Windows
> and Linux (not EGL) only I think. Other combinations may have issues.
> Revamping the window creation/offscreen code is on my list for the next
> release.

Aha, as simple as that. Thanks Ken.

Elvis

>
>
>
>
>
> On Fri, Oct 28, 2016 at 9:45 AM, Elvis Stansvik
> <elvis.stansvik at orexplore.com> wrote:
>>
>> 2016-10-28 15:31 GMT+02:00 Sophonet <vtk12af6bc42 at kant.sophonet.de>:
>> > Have you tried VTK 7.1.0.rc1? It includes the patch for combining on-
>> > and
>> > off-screen rendering (you need to set VTK_OPENGL_HAS_OSMESA=True). I
>> > have
>> > not tried it myself for OpenGL2, but if I recall correctly, the changes
>> > should not have been limited to OpenGL, but according to
>> > https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtkOpenGL.cmake,
>> > line
>> > 48, VTK_USE_OFFSCREEN_EGL (Offscreen) may not be combined with VTK_USE_X
>> > (Onscreen).
>>
>> Aha, thanks. I am using 7.1.0.rc1, but I'm not using that option. I'll
>> try turning it on.
>>
>> Do you happen to know if there's an example of off-screen rendering
>> with VTK 7.x somewhere? The one at
>>
>>     http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/OffScreenRendering
>>
>> is for <= 5.10.
>>
>> Elvis
>>
>> >
>> >
>> >
>> > Am 2016-10-28 15:18, schrieb Elvis Stansvik:
>> >>
>> >> Sorry for sort of necro-posting to this old thread, but I'm also
>> >> interested in if on- and off-screen rendering is possible with the
>> >> same build of VTK 7.x (using OpenGL2 backend in my case)? Or will I
>> >> need separate builds of VTK for this purpose? (and if so, if there are
>> >> plans to fix that).
>> >>
>> >> Thanks in advance,
>> >> Elvis
>> >>
>> >> 2016-02-08 10:52 GMT+01:00 Michael Bachmann
>> >> <Michael.Bachmann at synopsys.com>:
>> >>>
>> >>> Hello list!
>> >>> Hello Sophonet!
>> >>>
>> >>> First of all:
>> >>> => Thank you Sophonet for investigating this issue and for describing
>> >>> the
>> >>> patch to "VTKROOT/CMake/vtkOpenGL.cmake".
>> >>>      I applied your patch and it also re-enables offscreen rendering
>> >>> on a
>> >>> headless machine (were no X DISPLAY is available).
>> >>>
>> >>> Actually I really wonder why there are only a few posts about this
>> >>> issue.
>> >>> For the application I'm working on the ability of VTK7 to perform
>> >>> On-Screen and Off-Screen rendering with a single build of VTK is an
>> >>> absolute
>> >>> must-have! (Just like it was in VTK5 and VTK6)
>> >>>
>> >>> Please take the suggestion of Sophonet into account and re-enable it
>> >>> at
>> >>> least for the OpenGL rendering backend.
>> >>> Making this available for the OpenGL2 backend should also be
>> >>> considered.
>> >>>
>> >>> Building the software twice, e.g. like it is done for paraview
>> >>> (non-headless) and the paraview server (headless) is not an option for
>> >>> everyone.
>> >>> Actually is quite a big burden which has been silently put on the
>> >>> shoulders of VTK users.
>> >>>
>> >>> So please: Provide the facilities to perform On-Screen and Off-Screen
>> >>> rendering with a single build of VTK using OSMesa and X on Linux
>> >>> again!
>> >>>
>> >>> Best regards,
>> >>> Michael
>> >>>
>> >>>
>> >>>
>> >>> Date: Thu, 21 Jan 2016 14:54:46 +0100
>> >>> From: Sophonet <vtk12af6bc42 at kant.sophonet.de>
>> >>> To: vtkusers at vtk.org
>> >>> Subject: Re: [vtkusers] Combined on-screen and off-screen possible
>> >>>         with VTK-7.0.0 on linux/X?
>> >>> Message-ID: <ac1f14a73f567e2e8e5916a5c942dc04 at srv19.sysproserver.de>
>> >>> Content-Type: text/plain; charset=UTF-8; format=flowed
>> >>>
>> >>> As one further follow-up of my two earlier e-mails, I have partly
>> >>> answered the question myself... remember, my question is related to
>> >>> the
>> >>> OpenGL (not OpenGL2) rendering backend.
>> >>>
>> >>> Two observations:
>> >>>
>> >>> 1. It seems that the current CMake flag VTK_OPENGL_HAS_OSMESA is
>> >>> useless,
>> >>> since it does not set anything relevant (see my e-mail below) 2. It
>> >>> seems
>> >>> that combined on-screen / off-screen rendering is possible (on Mesa
>> >>> 9.2.3
>> >>> using the OpenGL rendering backend):
>> >>>
>> >>>     As a quick hack, I have changed VTKROOT/CMake/vtkOpenGL.cmake such
>> >>> that
>> >>>
>> >>>     * VTK_USE_OSMESA = True (triggers find_package OSMesa)
>> >>>     * VTK_USE_X = True (triggers find_package OpenGL)
>> >>>
>> >>>     ...and (at the bottom) vtk_module_link_libraries links to *both*,
>> >>> ${OSMESA_LIBRARY} and ${OPENGL_LIBRARIES}.
>> >>>
>> >>> After this hack, I can successfully launch interactive
>> >>> (glx-)renderwindows as well as set (occasionally) set
>> >>> SetOffscreenRenderingOn().
>> >>>
>> >>> Therefore, my suggestion would be to
>> >>>
>> >>> - remove VTK_OPENGL_HAS_OSMESA
>> >>> - change the vtkOpenGL.cmake such that VTK_USE_OSMESA is exposed as an
>> >>> advanced option and is not exclusive w.r.t. VTK_USE_X, but may be set
>> >>> at the
>> >>> same time.
>> >>>
>> >>> Any comments?
>> >>>
>> >>> Thanks,
>> >>>
>> >>>         Sophonet
>> >>>
>> >>>
>> >>> Am 2016-01-19 11:06, schrieb Sophonet:
>> >>>>
>> >>>> As a follow-up, I have done some more investigations myself and am
>> >>>> still lost:
>> >>>>
>> >>>> According to http://www.vtk.org/Wiki/VTK/OSMesa_Support, it seems
>> >>>> that
>> >>>> the legacy OSMesa library on linux systems is not needed anymore, but
>> >>>> that software renderers (such as gallium llvm) can provide off-screen
>> >>>> rendering themselves. Correct?
>> >>>>
>> >>>> When looking at VTKROOT/CMake/vtkOpenGL.cmake, it appears (not
>> >>>> perfectly sure though) that in this case VTK_OPENGL_HAS_OSMESA needs
>> >>>> to be turned on, since this flag sets VTK_CAN_DO_OFFSCREEN to 1.
>> >>>> However, it seems to me that VTK_CAN_DO_OFFSCREEN is not used
>> >>>> anywhere
>> >>>> else (did a thorough "grep" on that keyword in the source tree).
>> >>>>
>> >>>> It seems that Marcus (Hanwell) was responsible for many of these
>> >>>> changes in CMake - Marcus, can you help?
>> >>>>
>> >>>> What I would like to do is (see my first e-mail below) to
>> >>>> simultaneously use interactive rendering and (occasionally)
>> >>>> off-screen
>> >>>> rendering (for generating static images), which was possible on Linux
>> >>>> in earlier versions of VTK (e.g. 5.10), but is not possible anymore.
>> >>>>
>> >>>> Thanks,
>> >>>>
>> >>>>        Sophonet
>> >>>>
>> >>>>
>> >>>> Am 2016-01-15 12:44, schrieb Sophonet:
>> >>>>>
>> >>>>> Dear list,
>> >>>>>
>> >>>>> in my application, I would like to display a vtkRenderWindow for
>> >>>>> user
>> >>>>> interaction, but I also would like to use off-screen functionality
>> >>>>> simultaneously to render pre-defined views / snapshots that are
>> >>>>> shown
>> >>>>> as static images, like "thumbnails" for different datasets.
>> >>>>>
>> >>>>> This was possible in VTK 5.10 on linux (by creating a dedicated
>> >>>>> vtkRenderWindow per thumbnail, setting OffScreenRenderingOn,
>> >>>>> rendering and capturing the resulting image with a
>> >>>>> vtkWindowToImageFilter).
>> >>>>>
>> >>>>> In VTK-7.0.0.rc1, using the OpenGL rendering backend on Mesa 9.2.3,
>> >>>>> I
>> >>>>> now get a segfault with the following backtrace:
>> >>>>>
>> >>>>> (gdb) bt
>> >>>>> #0  0x00007fffd045db90 in xcb_glx_get_string_string_length ()
>> >>>>>    from /usr/lib64/libxcb-glx.so.0
>> >>>>> #1  0x00007fffd0cce605 in ?? () from /usr/lib64/libGL.so.1
>> >>>>> #2  0x00007fffd0ccc2b6 in ?? () from /usr/lib64/libGL.so.1
>> >>>>> #3  0x00007fffd14cd086 in
>> >>>>> vtkOpenGLExtensionManager::ReadOpenGLExtensions() ()
>> >>>>>    from
>> >>>>>
>> >>>>> /import/QUINTA/non-public/software/linux-install/quinta_gcc_debug/lib
>> >>>>> /libvtkRenderingOpenGL-7.0.so.1
>> >>>>> #4  0x00007fffd14cbd50 in vtkOpenGLExtensionManager::Update() ()
>> >>>>>    from
>> >>>>>
>> >>>>> /import/QUINTA/non-public/software/linux-install/quinta_gcc_debug/lib
>> >>>>> /libvtkRenderingOpenGL-7.0.so.1
>> >>>>> #5  0x00007fffd14cafd7 in
>> >>>>> vtkOpenGLExtensionManager::ExtensionSupported(char const*) ()
>> >>>>>    from
>> >>>>>
>> >>>>> /import/QUINTA/non-public/software/linux-install/quinta_gcc_debug/lib
>> >>>>> /libvtkRenderingOpenGL-7.0.so.1
>> >>>>> #6  0x00007fffd14ec8ea in vtkOpenGLRenderWindow::OpenGLInitContext()
>> >>>>> ()
>> >>>>>    from
>> >>>>>
>> >>>>> /import/QUINTA/non-public/software/linux-install/quinta_gcc_debug/lib
>> >>>>> /libvtkRenderingOpenGL-7.0.so.1
>> >>>>> #7  0x00007fffd14eae6d in vtkOpenGLRenderWindow::OpenGLInit() ()
>> >>>>>    from
>> >>>>>
>> >>>>> /import/QUINTA/non-public/software/linux-install/quinta_gcc_debug/lib
>> >>>>> /libvtkRenderingOpenGL-7.0.so.1
>> >>>>> #8  0x00007fffd1576932 in
>> >>>>> vtkXOpenGLRenderWindow::CreateOffScreenWindow(int, int) ()
>> >>>>>
>> >>>>> Besides a remark that probably there could be better error handling
>> >>>>> than just letting the app crash without an exception being thrown, I
>> >>>>> would like to know if joint on-screen rendering and off-screen
>> >>>>> rendering is still possible somehow with VTK-7.0.0.
>> >>>>>
>> >>>>> I have made two approaches when configuring via CMake: (i) Setting
>> >>>>> VTK_OPENGL_HAS_OSMESA=True (no effect, I think I remember that in
>> >>>>> earlier versions, this allowed OSMESA_INCLUDE_DIR etc. to be set;
>> >>>>> this is not the case anymore, so does this flag still do something?
>> >>>>> Note that for VTK 5.10 as mentioned above I did not have to set this
>> >>>>> explicitly), (ii) Setting USE_OFFSXCREEN_EGL=True - resulting in an
>> >>>>> error that this could not be combined with VTK_USE_X.
>> >>>>>
>> >>>>> On Windows, combining on-screen and off-screen rendering as
>> >>>>> described
>> >>>>> in the second paragraph is possible.
>> >>>>>
>> >>>>> Any suggestions would be welcome, the Wiki page I have found on this
>> >>>>> topic is not fully understandable to me
>> >>>>> (http://www.vtk.org/Wiki/VTK/OSMesa_Support; does this mean that I
>> >>>>> have to switch on VTK_OPENGL_HAS_OSMESA or not?...)
>> >>>>>
>> >>>>> Thanks,
>> >>>>>
>> >>>>>       sophonet
>> >>>>>
>> >>>>>
>> >>>>> _______________________________________________
>> >>>>> 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
>> >>>>
>> >>>> _______________________________________________
>> >>>> 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
>> >>>
>> >>>
>> >>>
>> >>> _______________________________________________
>> >>> 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
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>> > _______________________________________________
>> > 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
>> _______________________________________________
>> 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
>
>
>
>
> --
> Ken Martin PhD
> Chairman & CFO
> Kitware Inc.
> 28 Corporate Drive
> Clifton Park NY 12065
> 518 371 3971
>
> This communication, including all attachments, contains confidential and
> legally privileged information, and it is intended only for the use of the
> addressee.  Access to this email by anyone else is unauthorized. If you are
> not the intended recipient, any disclosure, copying, distribution or any
> action taken in reliance on it is prohibited and may be unlawful. If you
> received this communication in error please notify us immediately and
> destroy the original message.  Thank you.


More information about the vtkusers mailing list