Results 1 to 4 of 4

Thread: how to get z coordinate from the screen

  1. #1
    Guest

    how to get z coordinate from the screen

    Let's say I'm rendering a model on the screen using z-buffer,
    is there a way I can get the z coordinate of a given pixel (x,y) on the screen ?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Huntsville, AL. USA
    Posts
    302

    Re: how to get z coordinate from the screen

    Look for documentation on glUnproject(...) in the GLU documentation. Also do a search on this forum for 'gluUnproject'. There have been numerous discussions about that here.
    Obsessive - A word used by the lazy to describe the motivated.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    179

    Re: how to get z coordinate from the screen

    You can get the depth buffer value with an appropriate call to glReadPixels. Then you can use that z-value, together with the screen x and y to call gluUnproject.

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2002
    Location
    UK
    Posts
    27

    Re: how to get z coordinate from the screen

    Hi,

    Take a look at this it might help: http://www.opengl.org/discussion_boa...ML/009293.html

    Basically use glReadPixels with GL_DEPTH_COMPONENT. Just remember the depth buffer values aren't linear! I've never used gluUnproject but you can do it as in the above post. Don't know which would be quicker though.

    [This message has been edited by thelamberto (edited 07-30-2002).]
    ----------------------------
    Anthony Clare
    School of Engineering
    Cranfield University

Similar Threads

  1. How to convert screen coordinate to 3D world coordinate
    By happy_sweet_juice in forum OpenGL: General
    Replies: 6
    Last Post: 06-10-2017, 09:34 AM
  2. How to transform a screen coordinate to OpenGL coordinate
    By Caesirekin in forum OpenGL: Basic Coding
    Replies: 8
    Last Post: 12-11-2013, 09:29 AM
  3. From Screen Coordinate to OpenGL coordinate
    By apapaxionga in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 10-12-2011, 12:39 PM
  4. Screen Z coordinate
    By devdept in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-23-2008, 08:21 AM
  5. how to get screen coordinate from world coordinate?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-14-2003, 12:38 AM

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