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 2 of 2

Thread: gluUnProject depth issue

  1. #1
    Newbie Newbie
    Join Date
    Sep 2012
    Posts
    1

    gluUnProject depth issue

    Hello everyone this is my first thread. I`m a new to Opengl. I am recently trying to figure out how the depth buffer works. right now my task is to find the depth value in object space from window space. My camera is located in (0, 0, 2) point and it is looking at (0, 0, 0) point. Near plane distance is 1, far plane distance is 3, which i believe near plane should be at (0, 0, 1) and far plane should be at (0, 0, -1) in eye space.
    Window space has Z component which should be in an interval [0, 1] by default right. So if i transform a point (someX, someY, 0) from window space to object space by using gluUnproject , z component of the result point in object space must be equal to (someXX, someYY, 1) in object space. And z component of a point in window space is equal to 1, then the transformed point should be -1 right??? BUT, my result is when the z buffer is equal to 0 the result was the value( = 1) I expected. but if i set z to 1 then the result was -0.33. WHICH i don`t get it all? please help i`m stuck here for all day and couldn`t move forward.

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    Quote Originally Posted by mungunbat View Post
    So if i transform a point (someX, someY, 0) from window space to object space by using gluUnproject , z component of the result point in object space must be equal to (someXX, someYY, 1) in object space
    Perhaps. Could you write the call sequence you have for GL?

    Do you have
    glLoadIdentity();
    gluLookat(........);

    and what do you have as your perspective matrix?
    ------------------------------
    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);

Posting Permissions

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