Its certainly NOT impossible - however I am new to C programming, and even newer to OpenGL so I do not know exactly how. I have written a procedure to do exactly this for Delphi/Pascal, and it’s not that hard. Do just like you say - compare pixel by pixel. I think you can ignore the GL_QUADS element of this problem - after all, once you’ve compared and created the texture it doesn’t matter a fig what you texture with it.
I can post the Pascal code for this if it’s required, but I can’t imagine it’ll help other than serve as pseudo-code.
I do something similar, but I’m interested in the difference between two images (but that’s effectively the case when a-b=0). I use fragment programmes, though.
One way off the top of my head would involve rendering A to the frame buffer and then render B with the subtract blend equation. You’d then copy the result to a texture and define a fragment program that computed its alpha as ceil(r+g+b). That way you’d get alpha==0 everywhere r=g=b=0 and 1 otherwise.
if I understand you correctly, you want to know which pixels are different in 2 images.
A quite nice solution for this problem is the usage with a fragment shader:
You just render a full-screen quad with texture coordinates (orthogonal projection) and use a fragemtnshader to do a lookup into both textures and to compare them - if you use the fragmentshader you can decide how to compare the images. For example just Out = ImgA - ImgB, or something else.
If you are not interested in the difference value, but you - for example - just want to see all diferent pixels black on a white background you could just write something like:
if((ImgA-ImgB)!=0.0)
Out = 0.0;
else
Out = 1.0;
Another funny thing is the usage of occlusion queries if you want to know the number of different pixels: therefore you send an occlusion query before drawing the quad and you write a fragment shader with the “discard” (Cg) or “kill” (that´s the GLSL command I think) command - something like:
if((ImgA-ImgB)!=0.0)
Out = 0.0;
else
discard;
Then the occlusion query only counts the fragmetns which are different in both images so you´ll get back the number of different pixels without any readback and CPU calculation!