Reading Rendered Image

I am trying to read a rendered image
I have the command
in my code but all i get is black (0’s)
Please Help Me

Hi !

Maybe the pixel in the lower left (or upper left) corner is black ?, you have put 1 for both width and height ?, is this what you want ?


Originally posted by mikael_aronsson:
[b]Hi !

Maybe the pixel in the lower left (or upper left) corner is black ?, you have put 1 for both width and height ?, is this what you want ?


by changing x and y I scan the whole pic and all the pixels read as black even though some of them are green

So all components r,g,b and a are 0? Are you sure there is not a pointer problem or you have allocated enough memory and so on? do you want to post the code


Originally posted by Gavin:
do you want to post the code

setup procedures have been removed
the cube is being rendered correctly

var pxd:array[0…256000] of integer;

procedure TForm1.GLControl1Render(Sender: TObject);
var x,y:integer;
gluLookAt(5,5,5, 0,0,0, 5,5,1000);
for y:=0 to 168 do
for x:=0 to 184 do

a couple of things. why is pxd so big? if the image size rendered can change why are you not allocating it dynamically (setlength). I have a funny feeling that you need to declare a type, bugger I can’t remember. Something like
glubyte := ^array_pointer;


its a while since I did it in delphi. Also I would imagine that it will be quicker to read the whole image to an arrray and then access the array. Also look at using a array[x][y].record if you see what I mean. I think opengl can read from the buffer to a array of structures (records).

Originally posted by Gavin:
a couple of things…

at the moment it is so big because the last thing i need is errors from it overwriting the alocated space,
when I am finished I will be reading only a few pixels each time it is rendered. so speed isnt required,
the perpose of this it to enable me to locate what object is under the mouse pointer

I have discovered that by changing the background color I det a different result, I might be able to figure out what is wrong myself now , Will publish findings

Why not use a selection buffer?

I discovered I should have been using GL_BYTE not GL_INT
I also found the pic is upside down (easy fixed)

if the buffer was alocated for the size I required I would have had it 1/4 of the size glReadPixels needed

It is working but not the way I wanted
Will be posting a new topic for this problem