Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Crash after calling initializeOpenGLFunctions
Forum Updated to NodeBB v4.3 + New Features

Crash after calling initializeOpenGLFunctions

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nmthastings
    wrote on last edited by
    #1

    I'm trying to follow along with some of the official tutorials using OpenGL (specifically this one), and I am running in to an issue doing basic function initialization. I created this basic script to showcase my issue.

    from PySide6.QtOpenGLWidgets import QOpenGLWidget
    from PySide6.QtGui import QOpenGLFunctions
    from PySide6.QtWidgets import QApplication
    import sys
    
    class Test(QOpenGLWidget, QOpenGLFunctions):
    
        def __init__(self):
            super().__init__()
    
        def initializeGL(self) -> None:
            self.makeCurrent()
            print('Initializing')
            self.initializeOpenGLFunctions()
    
    if __name__ == '__main__':
        app = QApplication()
        win = Test()
        win.show()
        sys.exit(app.exec())
    

    The issue comes when the inherited QOpenGLWidget.initializeGL method is called, inside of which I call the inherited QOpenGLFunctions.initializeOpenGLFunctions method to... initialize the OpenGL Functions. This just leads to a hard application crash - no errors, no stacktrace. I have tried this using the QtGui.QOpenGLFunctions implementation and the QtGui.QOpenGLFunctions_version implementations, and all of them lead to this issue.

    I have an AMD Rx 5700xt using the latest drivers, and use Python 3.9.1, PySide6 version 6.1.2.

    Am I doing something wrong here? Can anyone else replicate this issue (perhaps on NVIDIA hardware)?

    eyllanescE 1 Reply Last reply
    0
    • N nmthastings

      I'm trying to follow along with some of the official tutorials using OpenGL (specifically this one), and I am running in to an issue doing basic function initialization. I created this basic script to showcase my issue.

      from PySide6.QtOpenGLWidgets import QOpenGLWidget
      from PySide6.QtGui import QOpenGLFunctions
      from PySide6.QtWidgets import QApplication
      import sys
      
      class Test(QOpenGLWidget, QOpenGLFunctions):
      
          def __init__(self):
              super().__init__()
      
          def initializeGL(self) -> None:
              self.makeCurrent()
              print('Initializing')
              self.initializeOpenGLFunctions()
      
      if __name__ == '__main__':
          app = QApplication()
          win = Test()
          win.show()
          sys.exit(app.exec())
      

      The issue comes when the inherited QOpenGLWidget.initializeGL method is called, inside of which I call the inherited QOpenGLFunctions.initializeOpenGLFunctions method to... initialize the OpenGL Functions. This just leads to a hard application crash - no errors, no stacktrace. I have tried this using the QtGui.QOpenGLFunctions implementation and the QtGui.QOpenGLFunctions_version implementations, and all of them lead to this issue.

      I have an AMD Rx 5700xt using the latest drivers, and use Python 3.9.1, PySide6 version 6.1.2.

      Am I doing something wrong here? Can anyone else replicate this issue (perhaps on NVIDIA hardware)?

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @nmthastings PySide accepts the double inherence in few cases so if possible it is better to use the composition.

      import sys
      
      from PySide6.QtGui import QOpenGLFunctions
      from PySide6.QtWidgets import QApplication
      from PySide6.QtOpenGLWidgets import QOpenGLWidget
      
      
      class Test(QOpenGLWidget):
          def __init__(self):
              super().__init__()
              self.opengl_functions = QOpenGLFunctions()
      
          def initializeGL(self) -> None:
              self.makeCurrent()
              print("Initializing")
              self.opengl_functions.initializeOpenGLFunctions()
      
      
      if __name__ == "__main__":
          app = QApplication()
          win = Test()
          win.show()
          sys.exit(app.exec())
      

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      1
      • N Offline
        N Offline
        nmthastings
        wrote on last edited by
        #3

        @eyllanesc Thanks for the tip. That does work to solve the issue. I find it odd that the official PySide documentation showcases the double inheritance case, but it doesn't seem to work. Is this just a case of the docs being out of date?

        eyllanescE 1 Reply Last reply
        0
        • N nmthastings

          @eyllanesc Thanks for the tip. That does work to solve the issue. I find it odd that the official PySide documentation showcases the double inheritance case, but it doesn't seem to work. Is this just a case of the docs being out of date?

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by eyllanesc
          #4

          @nmthastings Those examples are really a bad translation from C++ to Python, for example QOpenGLFunctions_3_2_Core f = QOpenGLContext.currentContext().versionFunctions<QOpenGLFunctions_3_2_Core>() is clearly not a valid python code. Another example is that the first code uses protected:, which clearly does not exist in python. In C++ you can declare float by placing "f" at the end( f.glClearColor(1.0f, 1.0f, 1.0f, 1.0f) ) since by default the numbers with decimals will be double but in python there is no equivalence.

          It seems that they have not given affection to the documentation so it would be that you report it as a bug

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved