I use readPixel for generating pictures from my OpenGL scene.
I would like to generate BMP pictures. For that, I need the bytes table returns by glReadPixel… I work in Java and all I arrive to produce is blackpictures. It seems that my Java code is correctly written for generating the picture.
I Think I have a problem with the byte table of glReadPixel… Here is my code
Its been ages since I’ve wriiten in Java, but memory tells me there me be some issue with the size of a byte??? Try set the array to GLubyte. Also, is there a reason your array isn’t HeightWidthBYTES_PER_PIXEL?
Joe
What do you mean by the colors not being correctly rendered? glReadPixels reads the rendered colors, not renders them?
One other thing I thought of that would be worth noting is to check out the documentation for glPixelStore. For glReadPixels you may need to set the GL_PACK_ALIGNMENT to 1, and for glWritePixels you may need to set GL_UNPACK_ALIGNMENT to 1.
And finally I do not have the same colours as the colour of my OpenGL scene.
But I just arrived to produce the pictures yersteday evening… I did not have time yet to work on it. I will try what you told me… and post new topic if I still have problems !
here is a page with the the correct view (up) and the picture I have (down). I t seems that the line crossing the picture and not appearing normally results from the deformation. It must the border of the picture… http://perso.wanadoo.fr/mathieu.rossier/Doc1.htm
I am sorry but you do not see it very well the colours on the pictures…In the correct view, you only have blue and red and in the picures, it seems difficult to see clearly what are the colours, like a mix…
I tried what Deiussum told to do (set up glPixelRead with glPixelStore) and it works perfectly ! The picture is not deformed anymore and the colours are perfect.
But the picture is still not in the right way… I will work on this…
Windows .BMP files havy the origin at the top left corner of the bitmap. I believe that the buffer filled out by glReadPixels has the origin at the bottom left corner. You cancorrect for this by setting the height member of the BITMAPINFOHEADER struct to be negative.
Originally posted by Mat:
[b]Hi,
I tried what Deiussum told to do (set up glPixelRead with glPixelStore) and it works perfectly ! The picture is not deformed anymore and the colours are perfect.
But the picture is still not in the right way… I will work on this…
thanks for your reply
it is exactly what happened… The left bottom corner was in fact in the left up corner… I arrived to change this by exercing a flip vertical rotation to the BufferedImage with the help of JAI APIS… (Java Advance Imaging)…