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.glFunc = QOpenGLContext.currentContext().versionFunctions(self.vp)

    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:


    Did you check what self.glFunc contains?


  • print(self.glFunc) returns

    <PyQt5._QOpenGLFunctions_2_1.QOpenGLFunctions_2_1 object at 0x12217e5e8>

    and print(dir(self.glFunc) returns a huge list:

    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.