Kitware / LookingGlassVTKModule

Other
15 stars 12 forks source link

Fix use of renderWindow returned by CreateLookingGlassRenderWindow on macOS #11

Open jcfr opened 3 years ago

jcfr commented 3 years ago

Due to an issue in upstream VTK preventing windows with negative position from being used, the looking glass renderwindow created on macOS does not appear on the hardware display but instead is shown on the main screen.

Similar problem has been fixed for Linux and Windows in https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7271 but we still need to address the problem with the underlying Rendering/OpenGL2/vtkCocoaRenderWindow.mm

To test potential fixes, you may run the command line associated with "TestDragon" test and specify -I.

I tried to comment these lines without success: https://gitlab.kitware.com/vtk/vtk/-/blob/36f8256268614a24efcb6c5c90e6fcf7104b3ff9/Rendering/OpenGL2/vtkCocoaRenderWindow.mm#L830-837

It may be worth looking into commenting the whole block: https://gitlab.kitware.com/vtk/vtk/-/blob/36f8256268614a24efcb6c5c90e6fcf7104b3ff9/Rendering/OpenGL2/vtkCocoaRenderWindow.mm#L821-845

jcfr commented 3 years ago

cc: @martinken

cquammen commented 3 years ago

I'm taking a look now, just getting oriented in the code.

cquammen commented 3 years ago

It may be worth looking into commenting the whole block: https://gitlab.kitware.com/vtk/vtk/-/blob/36f8256268614a24efcb6c5c90e6fcf7104b3ff9/Rendering/OpenGL2/vtkCocoaRenderWindow.mm#L821-845

That didn't do the trick I'm afraid.

cquammen commented 3 years ago

In a quick test, I was able to create the window on the second display be choosing a different NSScreen in OpenGL parlance. Now I just need to hook that into the render window creation.

cquammen commented 3 years ago

Here's a PR: https://github.com/Kitware/LookingGlassVTKModule/pull/12

jcfr commented 3 years ago

@cquammen Even after building the latest version of VTK with the remote module, running TestDragon display the window on the main screen instead of the LG hardware. I am adding some debug statement to vtkCocoaLookingGlassRenderWindow.mm to try to make sense of what the issue is.

cquammen commented 3 years ago

Did you update the remote module SHA-1 in VTK before trying it? I haven't gotten around to updating the VTK SHA-1.

jcfr commented 3 years ago

Did you update the remote module SHA-1 in VTK before trying it?

Let me try that.

I ended up building VTK directly because the updated code didn't work within Slicer. I will report back in a few.

jcfr commented 3 years ago

Good news.

The TestDragon test properly displays the window on the LG device. I now need to figure out what I need to fix on the Slicer side:

https://github.com/KitwareMedical/SlicerLookingGlass/blob/78fe5dd5b8351b0a1f58ac908cbb0cd7a606992b/LookingGlass/Widgets/qMRMLLookingGlassView.cxx#L170-L171