<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-06-29 22:52 GMT+02:00  <span dir="ltr"><<a href="mailto:clinton@elemtech.com" target="_blank">clinton@elemtech.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><span class=""><div><br></div><div><br></div><div><span>----- On Jun 29, 2016, at 10:45 AM, Elvis Stansvik <<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>> wrote:<br></span></div></span><div><span class=""><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;color:rgb(0,0,0);font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt"><p dir="ltr"><br> Den 29 juni 2016 6:07 em skrev "Shawn Waldon" <<a href="mailto:shawn.waldon@kitware.com" target="_blank">shawn.waldon@kitware.com</a>>:<br> >><br> >><br> >> I see, I may have misunderstood the role of QVTKWidget2 is vs QVTKWidget. I thought QVTKWidget2 was essentially a newer replacement for QVTKWidget, and to be preferred in new code.<br> >><br> >> I've also misunderstood a little how the two widgets work. I knew QVTKWidget2 makes use of the deprecated QGLWidget (and was in fact trying to make a similar Python class just recently, which uses QOpenGLWidget, but ran into some problems). But I also wrongly thought that QVTKWidget used QGLWidget, looking at the code I see now that it doesn't.<br> >><br> >> So in short: I have no great need for QVTKWidget2, functionality-wise. So if using it precludes using the OpenGL2 backend, I'll use QVTKWidget instead.<br> >><br> >> One thing I did like was that the code in QVTKWidget2 looked a little simpler/cleaner than the one QVTKWidget. It's always nice to be able to quickly check how something work.<br> >><br> >> An officially supported widget, based on QOpenGLWidget and supporting the OpenGL2 backend, would be the absolutely best of course. In fact, there's an answer on StackOverflow where a user posted his QVTKWidget2 hacked to work with QOpenGLWidget [1], perhaps it could be used as a starting point?<br> ><br> ><br> > So just to throw this out there, here is the situation as I understand it.  Ben (cc'd) can correct what I get wrong since he was one of the last to touch QVTKWidget2.<br> ><br> > QVTKWidget works fine with OpenGL2 if you are building against Qt4.  But when you build for Qt5 there are issues with creating the OpenGL context and letting Qt know the context is there and so some features of the OpenGL2 backend don't work right.</p><p dir="ltr">Do you know which features and if this is being worked out?</p></blockquote><div><br></div></span><div>I'm aware of some issues, and have looked briefly at Linux specific issues.</div><div>For instance, QVTKWidget::x11_setup_window is disabled for Qt5 and there has not been a replacement for that yet.</div></div></div></div></blockquote><div><br></div><div>Alright, good to know, thanks.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div><br></div><div>One possible workaround is to do something like the following in your main() before the QApplication is constructed.</div><div><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QSurfaceFormat</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">;</span></pre><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">setDepthBufferSize</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,128)">8</span><span style="color:rgb(0,0,0)">);</span></pre><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">setSamples</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">);</span></pre><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">setAlphaBufferSize</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,128)">8</span><span style="color:rgb(0,0,0)">);</span></pre><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">setStereo</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,128)">1</span><span style="color:rgb(0,0,0)">);</span></pre><pre style="text-indent:0px;margin:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.</span><span style="color:rgb(0,0,0)">setStencilBufferSize</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,128)">8</span><span style="color:rgb(0,0,0)">);<br></span><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QSurfaceFormat</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(0,0,0)">setDefaultFormat</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">);</span></pre></div><div><br></div></div></div></div></blockquote><div><br></div><div>Hm, but isn't QSurfaceFormat only about the context set up by the new (or well, somewhat new) QOpenGLWidget? If you mean you are using a context from QGLWidget (through QVTKWidget2), then shouldn't QGLFormat be used instead?<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div></div><div><br></div><div>It does fix some issues I'm able to replicate with the OpenGL backend.</div><div>For OpenGL2 backend, and possibly applicable to any platform, perhaps you could try adding a<br></div><div><pre style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;margin:0px;background-color:rgb(255,255,255)"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.setMajorVersion</span><span style="color:rgb(0,0,0)">(</span><span><span color="#000080" style="color:rgb(0,0,128)">3</span></span><span style="color:rgb(0,0,0)">);<br></span></pre></div><div><div style="font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)"><pre style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;margin:0px;background-color:rgb(255,255,255)"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">fmt</span><span style="color:rgb(0,0,0)">.setMajorVersion</span><span style="color:rgb(0,0,0)">(</span><span><span color="#000080" style="color:rgb(0,0,128)">2</span></span><span style="color:rgb(0,0,0)">);<br></span></pre></div></div></div></div></div></blockquote><div><br></div><div>Yes, this is what I did (and also fmt.setProfile(QSurfaceFormat.CompatibilityProfile) when experimenting with trying to get a QOpenGLWidget-backed widget working from Python (á la <a href="http://stackoverflow.com/questions/26944831/using-qvtkwidget-and-qopenglwidget-in-the-same-ui/26946040#26946040">http://stackoverflow.com/questions/26944831/using-qvtkwidget-and-qopenglwidget-in-the-same-ui/26946040#26946040</a>), in order for VTK to accept the context.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div><div style="font-family:arial,helvetica,sans-serif;font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255)"><pre style="font-size:16px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;margin:0px;background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0)"></span></pre></div></div><div>However, that may not be necessary because in the case of QVTKWidget, VTK is creating OpenGL contexts, not Qt.</div></div></div></div></blockquote><div><br></div><div>Right, that's what I also found out when looking at the code.<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div><br></div><div>I do not yet see a way for that information to be passed from vtkRenderWindow to QVTKWidget and down to Qt after the QApplication has been constructed.<br></div></div></div></div></blockquote><div><br></div><div>With "that information", do you mean information about what OpenGL version the render needs? No I guess not, I guess you just have to target a certain VTK version and use fixed numbers in the calls to .setMajor/MinorVersion.<br><br></div><div>But, like you say, with QVTKWidget, VTK is creating the OpenGL context, so there's nothing to .setMajorMinor/Version on, or am I missing something?<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div></div><div>Anyway, perhaps these workarounds will help.<br></div></div></div></div></blockquote><div><br></div><div>I'm not sure, if QSurfaceFormat is only for QOpenGLWidget, I would have to have a working QOpenGLWidget-based VTK widget first. But it was interesting that you set the depth/alpha/stencil buffers as well, since I only used it to set the number of samples when I experimented with QOpenGLWidget. Perhaps I should give it a try again.<br><br></div><div>In the end, I would still be very interested to hear if anyone knows what would be the best backend + VTK widget to use given the hardware I need to support.<br><br></div><div>Elvis<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div style="font-family:arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)"><div><div></div><div><br></div><div>Clint</div><div><br></div></div></div></div></blockquote></div><br></div></div>