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

Re: [pygame] Re: Accessing opengl surface as a numpy array



On Fri, Nov 12, 2010 at 11:57 AM, nbl <nblouveton@xxxxxxxxx> wrote:
Thank you Ian !

I just tried it and glReadPixels does the job ! However it clearly
slows down the rendering loop...

Probably because it is a copy operation, is there not a direct access
method to the pixels data ?

Sorry for my ignorance of OpenGL, I guess I would find a good book on
it !

Nicolas
Hi,
 
SDL exists as a software component usually (except for HW surfaces).  This allows operations to happen on the CPU.  Reading data from a SW surface is as simple as passing pointers around--there's no data copy, because the memory is already right there.

By contrast, OpenGL is a state machine based on the GPU.  The vertex, rasterization, and fragment stages all happen there.  This allows OpenGL to be very very fast, because it makes use of graphics hardware.  However, it of course means that if you want to get the data *back* from the graphics card, you'll need to transfer it across the (relatively slow) graphics bus.

A better question is probably to ask what you want to do.  Except for very specific cases, a full readback of the entire framebuffer is never truly necessary.

Ian