Can't use glReadPixels



  • I'm trying to use glReadPixels in my python3 application.

    Here's a segment of my code:

    self.vp = QOpenGLVersionProfile()
    self.vp.setVersion(2,1)
    self.glFunc = QOpenGLContext.currentContext().versionFunctions(self.vp)
    self.glFunc.glReadPixels(...)
    

    Regardless of what I pass to the function, I get an error:

    AttributeError: 'QOpenGLFunctions_2_1' object has no attribute 'glReadPixels'
    

    Any ideas what I'm doing wrong?


  • Moderators

    @GlowingApple said in Can't use glReadPixels:

    self.glFunc

    Did you check what self.glFunc contains?

    print(self.glFunc)
    print(dir(self.glFunc))
    


  • print(self.glFunc) returns

    <PyQt5._QOpenGLFunctions_2_1.QOpenGLFunctions_2_1 object at 0x12217e5e8>
    

    and print(dir(self.glFunc) returns a huge list: https://pastebin.com/QB4fjCBR

    Searching through the list there is no glReadPixels method. There is a GL_READ_PIXELS, but it's not a method, just an int. I searched for other similar functions containing read and/or pixels, but couldn't find anything else that seemed suitable.

    Is glReadPixels not available in OpenGL 2.1?

    I'm using Qt 5.8.0 and PyQt 5.8.0 on macOS 10.12.4 by the way.


  • Moderators

    @GlowingApple As far as I know glReadPixels is part of OpenGL 2.1
    But I'm not an OpenGL expert, maybe somebody else can help.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.