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

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



In fact, I work on a software implementing some processes on a
"visual" stream.

I don't need all frames' pixels as long as frames are spatially
sampled before all.

I probably could not read all the buffer but only update relevant
cells in a pre-allocated array.

Is it correct to use glReadPixels to read one pixel at a time, like
this :
glReaderPixels(x, y, 1, 1, ..., ...) ?

or is there a cleaner method ?

Thanks again !


On 12 nov, 20:30, Ian Mallett <geometr...@xxxxxxxxx> wrote:
> On Fri, Nov 12, 2010 at 11:57 AM, nbl <nblouve...@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