Results 1 to 3 of 3

Thread: read the depth buffer

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    10

    read the depth buffer

    How can I read the z coordinate value from the z buffer, for a given x & y coordinates?

    Requiered for a program where the user selects a 3D object (in perspective presentation) using the mouse's cursor.
    Thanks

  2. #2
    Member Contributor
    Join Date
    Mar 2003
    Location
    Suffolk, United Kingdom
    Posts
    99

    Re: read the depth buffer

    In a Windows app, I do something like this -
    Code :
    float fWinZ;
    int nViewport[4];
    glGetIntegerv(GL_VIEWPORT, nViewport);
     
    // reverse y coordinate for windows
    int y = nViewport[3] - y - 1;
    glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &fWinZ);
    Any good?

    [This message has been edited by Rog (edited 07-06-2003).]

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2003
    Posts
    10

    Re: read the depth buffer

    Thanks, i will check this.

    I have a new problem:
    I have a program that receives from the user control points of two B-Spline curves (de Boor points) and draws the surface with these curves as edges, connecting in a straight line between each two control points in different curves (ruled surface).
    My problem is the gluNurbsSurface method doesn't work correctly when the control points array is dynamically allocated (two or three dimentions array), where it works correctly when it is statically allocated. i didn't find how to operate it right.

    I would be grateful for any help anyone can give me with this.
    Thanks


    Originally posted by Rog:
    In a Windows app, I do something like this -
    Code :
    float fWinZ;
    int nViewport[4];
    glGetIntegerv(GL_VIEWPORT, nViewport);
     
    // reverse y coordinate for windows
    int y = nViewport[3] - y - 1;
    glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &fWinZ);
    Any good?

    [This message has been edited by Rog (edited 07-06-2003).]

Similar Threads

  1. Cannot read from depth buffer in FS
    By vampcat in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 09-28-2017, 06:19 PM
  2. Depth Buffer 2-way read
    By Jose Goruka in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 12-21-2009, 02:09 PM
  3. How to read Depth Buffer
    By Heema in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-30-2003, 03:25 AM
  4. depth buffer read
    By soconne in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 09-16-2003, 04:47 AM
  5. read depth buffer content.
    By A027298 in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 10-15-2002, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean