noname
noname

Reputation: 363

glReadPixels() fails, but replacing GL_RGBA with GL_RGB makes it work, inside pyglet

On Ubuntu 14.04, I'm testing an open source project which uses pyglet. I'm running /usr/bin/Xorg directly and separately, using the Nvidia driver with a Nvidia GPU.

The project has this part:

buffer = pyglet.image.get_buffer_manager().get_color_buffer()
image_data = buffer.get_image_data()

And pyglet.gl.lib.GLException: invalid operation occurs when it executes the second line.

Therefore I debugged using PYGLET_DEBUG_GL_* environment variables, and figured out that the error happens while calling glReadPixels(0, 0, 600, 400, 6407, 5121, <pyglet.image.c_ubyt).

The pyglet part of the stack trace is here: 1, 2

ColorBufferImage class originally uses GL_RGBA, and I tried changing it to use GL_RGB, by modifying the 2 lines here.

I didn't anticipate it, but GL_RGB made the glReadPixels() call work without the error, though I cannot use it since the open source project assumes it would be GL_RGBA.

I really want to know how to make GL_RGBA work...

Could someone please help me?

Update: I've just tried an another option, and I think changing the data type from GL_UNSIGNED_BYTE to GL_UNSIGNED_SHORT works (I also changed the buffer's primitive type from GLubyte to GLushort). If this is right, is this a bug of pyglet?

Upvotes: 0

Views: 663

Answers (0)

Related Questions