Results 1 to 5 of 5

Thread: How to set depth range in orthographic view

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    4

    How to set depth range in orthographic view

    Dear All,

    I'm trying to map the mouse cursor position from screen coordinates into orthographic view, for that I use
    Code :
    world_mouse_position = screen_mouse_position * inverse(MVPW)
    But it never returns the z value correctly( screen_mouse_position = (X,Y,0) ), interestingly it returns the correct values for the X and Y values in world coordinates, How am I supposed to fix that ?

    I already tried to set the depth range of glOrtho with playing around the Near/Far values, but that didn't help also.

    Regards,

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649
    So your input value is screen_mouse_position = (X,Y,0)? In window coordinates, with the default glDepthRange setting, 0 = near clip plane. If you have a specific point "under" your mouse click that you want to back transform, you need to feed that in instead of 0.

    Use glReadPixels() for instance to fetch back the window-space 0..1 depth value.

  3. #3
    Member Newbie
    Join Date
    Apr 2014
    Posts
    47
    An orthographic view flattens or projects a scene onto a plane without any perspective, so it looks like what you are getting is what I'd expect.

    What are you trying to do?

  4. #4
    Junior Member Newbie
    Join Date
    Mar 2014
    Posts
    4
    Dark Photon
    So your input value is screen_mouse_position = (X,Y,0)?
    If you have a specific point "under" your mouse click that you want to back transform, you need to feed that in instead of 0.
    Yes I'm reading the windows screen coordinates but this obviously doesn't have any z value,

    I don't have any specific point, mouse pointer may completely hoover in spatial space and sometimes may hoover over objects or not.

    What I expected to see is :
    If I set the ortho as glOrtho(left, right, top, bottom, znear=0 , zfar=1) ; then supplied mouse_screen_position(X,Y,0) should retrieve world_mouse_position(XWorld,YWorld, 0) if mouse_screen_position(X,Y,1) should retrieve world_mouse_position(XWorld,YWorld, 1).

    Am I wrong for this reasoning?

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,649
    If you mean eye-space instead of world-space (or you have an identify viewing transform), I believe what you say ("What I expected to see is") should be the case except that the near/far values are actually the negative of the eye-space Z values, just like with glFrustum.

Similar Threads

  1. How to render tiles are in the orthographic view only?
    By SamyyBlaze in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 07-17-2016, 01:06 AM
  2. Having trouble unprojecting an orthographic view
    By MrUNOwen in forum OpenGL: General
    Replies: 0
    Last Post: 06-14-2014, 03:48 PM
  3. Perspective Projection with an 'orthographic' view
    By Bruce Wheaton in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-08-2008, 05:28 PM
  4. Camera with Orthographic View
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-16-2006, 12:16 AM
  5. Zooming in Orthographic view?
    By in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-16-2001, 03:25 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