How to draw image in memory manually in pyglet?

Posted by Mossen on Game Development See other posts from Game Development or by Mossen
Published on 2013-05-21T23:31:46Z Indexed on 2013/11/12 22:05 UTC
Read the original article Hit count: 450

Filed under:

In pyglet, I want to create an image buffer in memory, then set the bytes manually, then draw it. I tried making a 3x3 red square like this in my draw() function:

imageData = pyglet.image.ImageData(3, 3, 'RGB', [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0 ])
imageData.blit(10, 10)

...but at runtime, Python complains:

ctypes.ArgumentError: argument 9: <type 'exceptions.TypeError'>: wrong type

Is this the right approach? Am I missing a step? How can I fix this?

© Game Development or respective owner

Related posts about pyglet