[PyQt] Unsure how to call glReadPixels

Jayson Kempinger jkempinger at decisionvis.com
Thu Mar 1 19:28:21 GMT 2018


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 <phil at riverbankcomputing.com> wrote:
> 
> On 2 Jun 2017, at 11:05 pm, Kempinger, Jayson <jkempinger at decisionvis.com <mailto:jkempinger at decisionvis.com>> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180301/35939755/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qopenglfunctions_4_1_core.sip.patch
Type: application/octet-stream
Size: 3622 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180301/35939755/attachment-0001.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180301/35939755/attachment-0004.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReadPixelsDemo.py
Type: text/x-python-script
Size: 4869 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180301/35939755/attachment-0001.bin>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180301/35939755/attachment-0005.html>


More information about the PyQt mailing list