Hi. I have a question about glReadPixels()…
I have a huge window with an image that takes up a relatively small amount of area. I need to get color information about the image after I draw it. The image is read in from a file.
Instead of reading information from the whole screen, I’m trying to read only information from the rectangle containing the image. So if the rectagle was, say, in the lower left corner of the screen and the corner of the image was at, say, (a,b), I might say something like
glReadPixels(a,b,image.length, image.height,…etc,…, anArray);
Where on the screen the image will appear is variable though, so I can’t just hardcode in where to read from.
I am not sure about a few things.
Will the glReadPixels() command stick the information in the upperleft corner of anArray (it’s a 2-D array)?
It seems like the glReadPixels() is not putting the correct information in anArray.
anArray is of a pre-defined size, so not all of anArray should contain information. But I cant seem to find where the glReadPixels() is putting the information in anArray.
I believe one solution would be to create a 2-D dynamic array, so that the array would be the correct size. But I’m not sure how to create a 2-d dynamic array.
Can someone help me out with this? Any suggestions would be greatly appreciated.