glReadPixels, read area out of windows bounds and glFrustum correcting coordinates.
I have app for painting on images. If user loads big image (witch is too big to fit window), the image is being moved more far away at z-axis to fit it. But when image is moved in z-axis my app is not painting as it should. It paints in wrong place. Here's image witch should describe my problem more clearly:
1. Image was moved by glTranslatef(0.0,0.0,-0.5);. Red circle shows where mouse was pressed and the blue where it was drawn.
2. Image zoomed to actual size ( glTranslatef(0.0,0.0,-0.1); ). Red circle shows that thing, witch we drawn in first image.
As you see drawn point in actual size is exactly in the same position of window where we pressed when image was zoomed out. So I guess OpenGL is listening to window coordinates, or something like that, and doesn't translates coordinates when it zoomed out.
Location's is being registered by:
location = [self convertPoint: [event locationInWindow] fromView:openGLView];
I nead glReadPixels to read OpenGL area witch is out of bounds of my window. As described above, image is being "resized" (textured quad is being drawn proportionally smaller) if its too big to fit to window. And user can get back to actual size. If he is back, and I do "save", then in saved image is visible only small part of edited image (only part witch was visible in window and because image was large, when in actual size mode, user can't see everything in window), and other part is just black color. Image:
App window looks like this
saved image (original image witch was edited is 3200x200, saved image size is exactly same size as original, just really doesn't looks like it should.).
Can anyone suggest me solution?