[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Directly accessing pixel data



JoN wrote:

I'm interested in the use of buffer objects in general, from pyopengl (so this
is more an opengl users list matter for me, forgive me).

Getting access to opengl buffer objects using ctypes is something I'm struggling
to get my head around, but there may be an even higher level way of doing it in
pygame??


You cannot get random access to texture buffer objects. Use glTexImage2D (or variant) to supply the initial data, and glTexSubImage2D to update it. ctypes is very flexible with what you can pass as a 'void *' to these functions, for example, a string, list, ctypes array will all work.
You can read back pixel data from a texture or buffer using glReadPixels, but this is not a common operation.


Vertex buffer objects can be mapped into system memory: use glMapBuffer to retrieve a 'void *' which you can then cast to a ctypes array of the correct size.

Pygame has no helping functions for OpenGL buffers or textures.

Alex.