Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

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

  1. #1
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41

    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.
    Click image for larger version. 

Name:	Screen Shot 2012-07-26 at 12.42.00 PM.jpg 
Views:	157 
Size:	13.6 KB 
ID:	821

    2. Image zoomed to actual size ( glTranslatef(0.0,0.0,-0.1); ). Red circle shows that thing, witch we drawn in first image.
    Click image for larger version. 

Name:	Screen Shot 2012-07-26 at 12.42.20 PM.jpg 
Views:	133 
Size:	12.1 KB 
ID:	822

    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:
    Code :
       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
    Click image for larger version. 

Name:	Screen Shot 2012-07-26 at 1.00.32 PM.jpg 
Views:	120 
Size:	12.0 KB 
ID:	823

    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.).
    Click image for larger version. 

Name:	qw.jpg 
Views:	140 
Size:	3.9 KB 
ID:	824


    Can anyone suggest me solution?

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,264
    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)
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Intern Newbie
    Join Date
    Jul 2012
    Posts
    41
    Thank you, i will try it just right now. And I'm still looking for solution for my first problem

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •