<div dir="ltr"><div>Hello,</div><div><br></div><div>Slight follow up to this as I omitted relevant information.</div><div><br></div><div>The offset arguments have also been accepting integer offsets cast as a void ptr. This presently works for glVertexAttribPointer as demonstrated in the code snippet above. One potential solution would be to have glDrawElements take a PYQT_OPENGL_BOUND_ARRAY instead of a PYQT_OPENGL_ARRAY.</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 13, 2024 at 2:54 PM Ognyan Moore <<a href="mailto:ognyan.moore@gmail.com">ognyan.moore@gmail.com</a>> wrote:<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 dir="ltr"><div>Hello,</div><div><br></div><div>There seems to be an issue with the binding on glDrawElements, specifically the indices attribute. Issue can be demonstrated w/ the following code:</div><div><br></div><div>import struct<br><br>from PyQt6 import QtGui, QtOpenGL<br>OFFSET = lambda x : x<br><br># from PySide6 import QtGui, QtOpenGL<br># from shiboken6 import VoidPtr<br># OFFSET = lambda x : VoidPtr(x)<br><br>class MyWidget(QtOpenGL.QOpenGLWindow):<br> def initializeGL(self):<br> vtx = struct.pack('9f', 0, -1, -1, 1, -1, -1, 1, 1, 1) # 1 bogus float in front<br> ind = struct.pack('6H', 0, 1, 2, 2, 3, 1)<br><br> self.m_vbo = QtOpenGL.QOpenGLBuffer(QtOpenGL.QOpenGLBuffer.Type.VertexBuffer)<br> self.m_vbo.create()<br> self.m_vbo.bind()<br> self.m_vbo.allocate(vtx, len(vtx))<br><br> self.m_ibo = QtOpenGL.QOpenGLBuffer(QtOpenGL.QOpenGLBuffer.Type.IndexBuffer)<br> self.m_ibo.create()<br> self.m_ibo.bind()<br> self.m_ibo.allocate(ind, len(ind))<br><br> GL = self.get_functions()<br> GL.glEnableVertexAttribArray(0)<br> # specifying an integer offset to skip past the bogus float works for glVertexAttribPointer<br> GL.glVertexAttribPointer(0, 2, 0x1406, False, 0, OFFSET(4))<br><br> def get_functions(self):<br> vp = QtOpenGL.QOpenGLVersionProfile()<br> vp.setVersion(2, 0)<br> return QtOpenGL.QOpenGLVersionFunctionsFactory.get(vp, self.context())<br><br> def paintGL(self):<br> GL = self.get_functions()<br> GL.glClear(0x4000)<br><br> # draw 2 triangles separately to demonstrate the issue<br><br> try:<br> # unlike the binding for glVertexAttribPointer, we are not able to<br> # supply an integer offset.<br> GL.glColor3f(1, 0, 0)<br> GL.glDrawElements(4, 3, 0x1403, OFFSET(None))<br><br> GL.glColor3f(0, 1, 0)<br> GL.glDrawElements(4, 3, 0x1403, OFFSET(6))<br> except TypeError as e:<br> # should have been defined as PYQT_OPENGL_BOUND_ARRAY?<br> print(e)<br><br>app = QtGui.QGuiApplication([])<br>win = MyWidget()<br>win.show()<br>app.exec()</div><div><br></div><div><br></div><div>the except TypeError as e: print(e) outputs the following:</div><div><br></div><div>glDrawElements(self, mode: int, count: int, type: int, indices: PYQT_OPENGL_ARRAY):<br>glDrawElements(self, mode: int, count: int, type: int, indices: PYQT_OPENGL_ARRAY):</div><div><br></div><div>the <a href="https://registry.khronos.org/OpenGL-Refpages/gl4/html/glDrawElements.xhtml" target="_blank">OpenGL docs</a> indicate it should be a pointer to the location where the indices are stored. With the pyside bindings, using VoidPtr(x) seems to be sufficient. When using PyQt bindings, in other places we've often gotten what's needed for similar arguments using lambda expressions, which we expected to be able to do the same here as well.</div><div><br></div><div>Thanks,</div><div>Ogi<br></div></div>
</blockquote></div>