glDrawPixels&glReadPixels Unmatched??

I have set up an array image1[]in the host memory, each element in which stores the rgba value(format:GLfloat).Then I use
glDrawPixels(width,height,GL_RGBA,GL_FLOAT,image1) to draw a rectangle image on the screen.
Afterwards, I want to use glReadPixels to restore the buffer image to the host memory (in an array image2[]), but I find the data I get from the “glReadPixels” (image2[])is not the same as the data I use to draw the rectangle image (image1[])
what is the problem?
(I have used the glPixelStorei to set up the correct format of the GL_ALIGNMENT, and I only use single buffer,and I have used the glGetIntegerv to get the raster positon to use in the glReadPixels as the first two parms)
Can someone help me? Thanks in advance!

What differences are you seeing? Could this be accounted for by the precision of the framebuffer & GL_DITHER?

You don’t even state the formats you’re drawing so it’s difficult to tell.

In my opinion, the two arraies should be the same,(am i right??)because image2 is from the buffer,and the buffer is from the image1.However, the elementsi observed in the image2 is irrelevant to those in image1.
thanks!
the program is as follows:
GLint raspos[4];
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_ALPHA,GL_DST_ALPHA);
glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glPixelStorei (GL_PACK_ALIGNMENT, 1);
glDrawPixels(this->width, this->height, GL_RGBA, GL_FLOAT, pImage);
glGetIntegerv(GL_CURRENT_RASTER_POSITION,raspos);
glReadPixels(raspos[0],raspos[1],this->width,this->height,GL_RGBA,GL_FLOAT, m_BlendImage0.pImage);

Originally posted by wusheng:
I have set up an array image1[]in the host memory, each element in which stores the rgba value(format:GLfloat). Then I use
glDrawPixels(width,height,GL_RGBA,GL_FLOAT,image1) to draw a rectangle image on the screen.
Afterwards, I want to use glReadPixels to restore the buffer image to the host memory (in an array image2[]), but I find the data I get from the “glReadPixels” (image2[])is not the same as the data I use to draw the rectangle image (image1[])
what is the problem?

The data will be converted to the format of the buffer you are drawing to. glReadPixels will then convert the data back into your desired GLfloat format. So if your drawing to an ARGB8 buffer each of your floats will be converted to an unsigned byte and glReadPixel will take that byte and convert it back to an float.

Of course you loose a lot of precission in the process.

Looks like you want to use OpenGL to do some offline alphablending, in this case you are better of doing it manually.

To elaborate a bit more on my previous post:

No you cant assume that the data you read back using glReadPixels() is exactly the same you pass to glDrawPixels().

It depends on the format of the buffer you are drawing too, blending, multisampling, pixelzoom, … and last but not least OpenGL allows a certain amount of invariance on the fragment level.

OpenGL is a graphics library, not a database.

And please dont cross post in the future.

In fact, i want to test if i can get an accelerated effect by using OpenGL. I have done the blending work manually.However, I cannot solve the problem of reading the data from buffer(as pointed above).So i am a little dispointed.
I can bear the result of losing some precission during the data switching(from float to UINT or UINT to float),but it seems the results are not correct at all.All of these happen when i use glreadPixels().I am puzzled.
I am sorry to cross post.
Thank you very much.

hey wusheng, can you post more code ? i get the feeling it might by a simple glitch somewhere in your code, if it’s as bad as you say …