glReadPixels, read area out of windows bounds and glFrustum correcting coordinates.

1st problem:

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.
    [ATTACH=CONFIG]241[/ATTACH]

  2. Image zoomed to actual size ( glTranslatef(0.0,0.0,-0.1); ). Red circle shows that thing, witch we drawn in first image.
    [ATTACH=CONFIG]242[/ATTACH]

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];

Any solutions?

2nd problem:

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
[ATTACH=CONFIG]243[/ATTACH]

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.).
[ATTACH=CONFIG]244[/ATTACH]

Can anyone suggest me solution?

I don’t know what the first problem is.
For the second, if you need to create a render buffer. You can make it bigger than your viewport.
http://www.opengl.org/wiki/Framebuffer_Objects
http://www.opengl.org/wiki/Framebuffer_Object_Examples
You should look at #6, Quick example, render_to_buffer (p-buffer replacement)

Thank you, i will try it just right now. And I’m still looking for solution for my first problem