<div dir="ltr">On Thu, Mar 12, 2015 at 7:23 PM, Erik Hvatum <span dir="ltr"><<a href="mailto:ice.rikh@gmail.com" target="_blank">ice.rikh@gmail.com</a>></span> wrote:<br><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Mar 11, 2015 at 5:45 PM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>On 11/03/2015 9:30 pm, Peter Jensen wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hi<br>
<br>
I have a problem using the QOpenGLWidget.<br>
I get an import error concerning missing module: PyQt5._QOpenGLFunctions_2_1<br>
Among many other things, I have tried forcing OpenGL 2.0 with<br>
QSurfaceFormat() and setVersion, but it doesn’t appear to make any<br>
difference.<br>
</blockquote>
<br></span>
If you mean that it still tries to import _QOpenGLFunctions_2_1 then you haven't managed to tell it to use OpenGL 2.0.<span><br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Using Windows 8.1, Python 3.4.2(x32) and PyQt5-5.4.1-gpl-Py3.4-Qt5.4.1-x32<br>
<br>
Running the included example hellogl.py results in:<br>
File "C:/Python34/Lib/site-packages/PyQt5/examples/opengl/hellogl.py", line<br>
142, in initializeGL<br>
<a href="http://self.gl" target="_blank">self.gl</a> = self.context().versionFunctions()<br>
ImportError: No module named 'PyQt5._QOpenGLFunctions_2_1'<br>
<br>
Hellogl.py based on QGLWidget in PyQT 5.4.0 examples works.<br>
<br>
Any help that would make QOpenGLWidget work, is very welcome.<br>
</blockquote>
<br></span>
I'm still discovering what's needed to make things work on all machines. I'll add the 2.1 module in the next installer.<br>
<br>
Phil<br></blockquote></span></div></div></div></blockquote><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""></span><br></div><div class="gmail_quote"><span class=""></span><div>Of course, it is possible to request a lesser version functions ball. Here's what I do (feel free to copy/paste):<br><br>
<div style="color:rgb(0,0,0);background-color:rgb(245,245,245);font-style:normal;font-weight:normal;text-decoration:none">
<pre><span style="color:rgb(128,0,128)">def</span><span> </span><span style="color:rgb(0,0,176)">GL</span><span>():</span>
<span> </span><span style="color:rgb(128,0,128)">global</span><span> </span><span>_GL</span>
<span> </span><span style="color:rgb(128,0,128)">if</span><span> </span><span>_GL</span><span> </span><span style="color:rgb(128,0,128)">is</span><span> </span><span style="color:rgb(0,0,255)">None</span><span>:</span>
<span> </span><span>context</span><span> </span><span>=</span><span> </span><span>Qt</span><span>.</span><span>QOpenGLContext</span><span>.</span><span style="color:rgb(0,0,176)">currentContext</span><span>()</span>
<span> </span><span style="color:rgb(128,0,128)">if</span><span> </span><span>context</span><span> </span><span style="color:rgb(128,0,128)">is</span><span> </span><span style="color:rgb(128,0,128)">not</span><span> </span><span style="color:rgb(0,0,255)">None</span><span>:</span>
<span> </span><span style="color:rgb(128,0,128)">try</span><span>:</span>
<span> </span><span>_GL</span><span> </span><span>=</span><span> </span><span>context</span><span>.</span><span style="color:rgb(0,0,176)">versionFunctions</span><span>()</span>
<span> </span><span style="color:rgb(128,0,128)">except</span><span> </span><span style="color:rgb(0,0,255)">ImportError</span><span>:</span>
<span> </span><span style="color:rgb(0,128,0)"># PyQt5 v5.4.0 and v5.4.1 provide access to OpenGL functions up to OpenGL 2.0, but we have made</span>
<span> </span><span style="color:rgb(0,128,0)"># an OpenGL 2.1 context. QOpenGLContext.versionFunctions(..) will, by default, attempt to return</span>
<span> </span><span style="color:rgb(0,128,0)"># a wrapper around QOpenGLFunctions2_1, which has failed in the try block above. Therefore,</span>
<span> </span><span style="color:rgb(0,128,0)"># we fall back to explicitly requesting 2.0 functions. We don't need any of the C _GL 2.1</span>
<span> </span><span style="color:rgb(0,128,0)"># constants or calls, anyway - these address non-square shader uniform transformation matrices and</span>
<span> </span><span style="color:rgb(0,128,0)"># specification of sRGB texture formats, neither of which we use.</span>
<span> </span><span>vp</span><span> </span><span>=</span><span> </span><span>Qt</span><span>.</span><span style="color:rgb(0,0,176)">QOpenGLVersionProfile</span><span>()</span>
<span> </span><span>vp</span><span>.</span><span style="color:rgb(0,0,176)">setProfile</span><span>(</span><span>Qt</span><span>.</span><span>QSurfaceFormat</span><span>.</span><span>CompatibilityProfile</span><span>)</span>
<span> </span><span>vp</span><span>.</span><span style="color:rgb(0,0,176)">setVersion</span><span>(</span><span style="color:rgb(0,78,130)">2</span><span>,</span><span> </span><span style="color:rgb(0,78,130)">0</span><span>)</span>
<span> </span><span>_GL</span><span> </span><span>=</span><span> </span><span>context</span><span>.</span><span style="color:rgb(0,0,176)">versionFunctions</span><span>(</span><span>vp</span><span>)</span>
<span> </span><span style="color:rgb(128,0,128)">if</span><span> </span><span style="color:rgb(128,0,128)">not</span><span> </span><span>_GL</span><span>:</span>
<span> </span><span style="color:rgb(128,0,128)">raise</span><span> </span><span style="color:rgb(0,0,255)">RuntimeError</span><span>(</span><span style="color:rgb(0,128,128)">'Failed to retrieve OpenGL wrapper namespace.'</span><span>)</span>
<span> </span><span style="color:rgb(128,0,128)">if</span><span> </span><span style="color:rgb(128,0,128)">not</span><span> </span><span>_GL</span><span>.</span><span style="color:rgb(0,0,176)">initializeOpenGLFunctions</span><span>():</span>
<span> </span><span style="color:rgb(128,0,128)">raise</span><span> </span><span style="color:rgb(0,0,255)">RuntimeError</span><span>(</span><span style="color:rgb(0,128,128)">'Failed to initialize OpenGL wrapper namespace.'</span><span>)</span>
<span> </span><span style="color:rgb(128,0,128)">return</span><span> </span><span>_GL</span></pre></div>
FYI, the _GL.initializeOpenGLFunctions() call is unnecessary, but my OCD demands it.<br></div><div><br></div><div>Cheers,<br></div><div>Erik<br><br></div><div>PS: apologies to Phil for sending this reply directly to his email address and not the list the first time around...<br> </div></div></div></div></div><br></div></div></div>