Unsure how to call glReadPixels

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Unsure how to call glReadPixels

Kempinger, Jayson
I'm trying to use glReadPixels in my python3 application (python 3.6.1, Qt 5.8.0, and PyQt 5.8.0).

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'

Running print(dir(self.glFunc) returns a huge list of functions but does not include glReadPixels or any variation that I can find (there's GL_READ_PIXELS but it's an int).

Am I looking in the wrong place for this function?  I posted to a Qt forum but have not received an answer, so I'm hoping someone can help me here!

Thanks!
Jayson

_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Unsure how to call glReadPixels

Phil Thompson-5
On 2 Jun 2017, at 11:05 pm, Kempinger, Jayson <[hidden email]> wrote:

>
> I'm trying to use glReadPixels in my python3 application (python 3.6.1, Qt 5.8.0, and PyQt 5.8.0).
>
> 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'
>
> Running print(dir(self.glFunc) returns a huge list of functions but does not include glReadPixels or any variation that I can find (there's GL_READ_PIXELS but it's an int).
>
> Am I looking in the wrong place for this function?  I posted to a Qt forum but have not received an answer, so I'm hoping someone can help me here!

It's not implemented simply because I don't know what the best way to do it is.  Specifically how to I calculate how much data will be returned so that I can allocate a buffer of the correct size?

Thanks,
Phil
_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|

Re: Unsure how to call glReadPixels

Kempinger, Jayson
Hi Phil,

I finally got around to working on an implementation of glReadPixels.  I'm not very experienced with SIP and PyQt's code-base, so I'm sure the code could use some refinements/generalization, but the attached patch compiles and runs smoothly on my system.  The patch was generated against the PyQt 5.10.1 commercial source.  I also included a Python demo for testing.  If you run into any issues, or have any questions, please let me know!

Thank you,
Jayson




On Jun 6, 2017, at 10:39 AM, Phil Thompson <[hidden email]> wrote:

On 2 Jun 2017, at 11:05 pm, Kempinger, Jayson <[hidden email]> wrote:

I'm trying to use glReadPixels in my python3 application (python 3.6.1, Qt 5.8.0, and PyQt 5.8.0).

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'

Running print(dir(self.glFunc) returns a huge list of functions but does not include glReadPixels or any variation that I can find (there's GL_READ_PIXELS but it's an int).

Am I looking in the wrong place for this function?  I posted to a Qt forum but have not received an answer, so I'm hoping someone can help me here!

It's not implemented simply because I don't know what the best way to do it is.  Specifically how to I calculate how much data will be returned so that I can allocate a buffer of the correct size?

Thanks,
Phil


_______________________________________________
PyQt mailing list    [hidden email]
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

qopenglfunctions_4_1_core.sip.patch (3K) Download Attachment
ReadPixelsDemo.py (4K) Download Attachment