a problem with glreadpixel

Hi
I want to use glReadPixel to catch pixels color and map them on the plane. In other words I want to make a plane like a monitor that be able to show framebuffer realtime. But when I use it the returned data is nil.
I use Delphi for programming.

var Data:Pointer;

glDrawBuffer(GL_BACK);
…drawing
glFlush;
glreadPixel(0,0,100,100,GL_RGBA,GL_BITMAP,Data)

Data is Nil after this command. Why?
I try some of other Option. But either make an exception error or Data=Nil.

please help me.
thanks a lot

GL_BITMAP is for black and white…

replace it with GL_UNSIGNED_BYTE and test again.

Hi,
I test it to. But it gives Exeption Error.
I dont Know why?
Is there any source code too help me?

thanks

‘Data’ must be a <u>pointer</u> to 1001004=40000 bytes of memory, which you must allocate beforehand.

I don’t know how to do that in VB, but many people had trouble with pointers and VB.

Yes, you need to allocate the memory for your array. Never worked with Delphi so I’m not sure how to do that.

If you were working with VB as zeckensack mistakenly thought, you would use the redim command.

Dim array() as float

Redim array(size)

Or something like that.

Yes, thanks for the correction.

I have forgotten off my head, but will post the code for delphi later…