PDA

View Full Version : a problem with glreadpixel



shafa_hn
08-25-2002, 11:58 PM
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

Mazy
08-26-2002, 12:18 AM
GL_BITMAP is for black and white..

replace it with GL_UNSIGNED_BYTE and test again.

shafa_hn
08-26-2002, 12:40 AM
Hi,
I test it to. But it gives Exeption Error.
I dont Know why?
Is there any source code too help me?

thanks

zeckensack
08-26-2002, 02:58 AM
'Data' must be a <u>pointer</u> to 100*100*4=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.

Deiussum
08-26-2002, 04:35 AM
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.

zeckensack
08-26-2002, 08:11 AM
Yes, thanks for the correction.

Gavin
08-27-2002, 12:21 AM
I have forgotten off my head, but will post the code for delphi later..