PDA

View Full Version : Buffers Are Interfering With Each Other; glReadPixels fails



granters
06-27-2017, 01:51 PM
I have an application in a GUI made in wx.Python. I'm rendering graphics with gl* calls, on wx.glcanvas instances.

I init() them like so:
glcanvas.GLCanvas.__init__(self, parent, -1)

get their contexts:
self.context = glcanvas.GLContext(self)

set their contexts in OnPaint():
self.SetCurrent(self.context)

So, when I only have one glcanvas, everything works fine. But I want to have multiple canvases, rendering different things in the GUI. Their contexts and buffers seem to be interfering with each other, though. I get a lot of issues, most of the time I've been able to 'band aid' over them. But I'm trying to access pixels in the back buffer in one of my canvases, and now I can't do this, since adding the other canvas to the program. Just wondering if anyone has any experience with these issues? Has anyone rendered on multiple windows or canvases in Py.OpenGL? I believe the buffers are messed up, which is causing the exception thrown from GL\images.py.

My exception details:
ArgumentError: argument 7: <type 'exceptions.TypeError'>: wrong type

pixelRed = glReadPixels(x, viewport[3] - y, 1, 1, GL_RED, GL_BYTE)[0][0]
File "C:\Python27\lib\site-packages\OpenGL\GL\images.py", line 362, in glReadPixels
imageData


this function that throws this is in images.py,
GL_1_1.glReadPixels(
x,y,width,height,
format,type,
imageData
)

GClements
06-28-2017, 05:13 AM
Has anyone rendered on multiple windows or canvases in Py.OpenGL?

Yes. Here's an example program (https://pastebin.com/QitXcmcw) using wxPython and PyOpenGL. The contexts aren't sharing data.

granters
06-30-2017, 02:43 PM
Yes. Here's an example program (https://pastebin.com/QitXcmcw) using wxPython and PyOpenGL. The contexts aren't sharing data.

This is a great example, thank you so much!