I am using GLUT for my windowing system to output some images onto the screen. I also want to output the images to files. This has been a challenge. In some window resolution (such as 256x256, 1024x1024, 1920x1200), glReadPixels produce exact same image files as the screen. However when I resize the window (ex/ 655x652, 529x566 and do the screen capturing, images are zagged and seems like pixels have shifted linearly.
Any help will be appreciated!
EDIT - I am adding some code leading up to the glReadPixels call.
glGetIntegerv(GL_VIEWPORT, dimensions);
width = dimensions[2];
height = dimensions[3];
screencapture = (unsigned char*)malloc(width*height*sizeof(unsigned char));
glReadPixels(0,0,width, height, GL_GREEN, GL_UNSIGNED_BYTE, screencapture);
EDIT2 - I forgot to mention resizing the window with the mouse some times do produce good images. I guess it happens when I get the resolution just right.