[vtkusers] VTK 6.2 and PyQt5?

clinton at elemtech.com clinton at elemtech.com
Fri Feb 5 13:58:29 EST 2016


----- On Feb 5, 2016, at 11:15 AM, Elvis Stansvik <elvis.stansvik at orexplore.com> wrote: 

> 2016-02-05 18:46 GMT+01:00 < clinton at elemtech.com > :

>> ----- On Feb 5, 2016, at 10:26 AM, David Gobbi < david.gobbi at gmail.com > wrote:

>>> On Fri, Feb 5, 2016 at 9:15 AM, Elvis Stansvik < elvis.stansvik at orexplore.com >
>>> wrote:

>>>> Alright, so you've heard about it before? Should there ever be a need for
>>>> QGLWidget, or should it be reported as a bug?

>>>> My system:

>>>> Thinkpad T440s
>>>> Intel HD Graphics 4400
>>>> Qt 5.5.1 / PyQt5 5.4.2 / VTK 6.2.0

>>>> All installed from Kubuntu repos (with backports repositories enabled).

>>>> I have no reason not to use QGLWidget instead of QWidget, so it's not a big
>>>> problem. I was mostly curious if others have seen this problem.

>>> Yes, the depth buffer for the context seems to be missing. The person who
>>> submitted the QGLWidget patch had exactly the same issue:
>>> https://gitlab.kitware.com/vtk/vtk/merge_requests/1097

>>> That was for linux on a virtual machine, so I thought it was the fault of the
>>> virtual machine. But maybe it wasn't after all!

>>> I use linux as well, with NVidia graphics, for me it works without QGLWidget.

>>> - David

>> Perhaps the following explanation will clear some things up, and help people
>> understand when and why the problems shows up.

>> The C++ QVTKWidget class addresses this issue by controlling the X11 visual when
>> creating the window. See QVTKWidget::x11_setup_window().
>> I don't think this issue is related to what OpenGL driver is used, but rather
>> what X11 visual is the default or chosen by Qt.

>> On Linux, you can run
>> $ xdpyinfo | default
>> to get the default visual for the X11 server.
>> In my case, its
>> default visual id: 0x21

>> Then you run glxinfo to look up the capabilities of the default visual.

>> In my case, visual 0x21 has the following capabilities.
>> visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav
>> id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat
>> ----------------------------------------------------------------------------
>> 0x021 24 tc 0 24 0 r y . 8 8 8 0 . s 4 24 8 16 16 16 16 0 0 None

>> My default visual 0x21 supports a depth buffer, but not alpha. To get alpha
>> working with VTK, a different visual would be needed.

>> When mixing OpenGL and X11, the application code is responsible for choosing the
>> X11 visual that supports the capabilities one wants to get from OpenGL.
>> By using QWidget, you get the default visual, unless overridden. By using
>> QGLWidget, you possibly get another one, depending on the logic in QGLWidget
>> based on QGLFormat. The default QGLFormat may or may not give you what you are
>> expecting to get with VTK. Also, when using QGLWidget, you now have a window
>> with 2 opengl contexts created for it. One by VTK, and another by Qt - and I
>> find that confusing.

>> In Qt 4.8, the QApplication constructor had support for specifying visuals, but
>> that appears to have gone away with Qt 5.

> Thanks for the detailed info Clint, I'm still digesting it.

> On my system I get:

> [estan at pyret ~]$ xdpyinfo | grep default
> default screen number: 0
> default colormap: 0x22
> default number of colormap cells: 256
> default visual id: 0x20
> [estan at pyret ~]$ glxinfo | grep 0x020
> 0x020 24 tc 0 32 0 r y . 8 8 8 8 . . 0 24 8 0 0 0 0 0 0 None

> I'm not sure what these means.

> But in any case, is there really no Qt 5 API which VTK could use to request an
> X11 visual that has the required capabilities?

> Thanks for shedding light on this, I'll go with QGLWidget when working on my
> laptop for now. But yes, I also find the double GL contexts strange.

You can try passing into QApplication the visual you want to use. 
QApplication(['QVTKRenderWindowInteractor', '-visual', '25']) 

Perhaps trying different visuals listed by glxinfo will help in understanding the issue. 

Clint 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160205/c9d7435b/attachment.html>


More information about the vtkusers mailing list