Results 1 to 5 of 5

Thread: how does glDepthRange work?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Posts
    318

    how does glDepthRange work?

    My vertex cords are :
    Code :
    GLfloat vertices[]=
        {
            0.5f,0.5f,0.5f,                                   
            -0.5f,0.5f,0.5f,
            -0.5f,-0.5f,0.5f,
            0.5f,-0.5f,0.5f,//face 1
     
            0.5f,-0.5f,-0.5f,
            -0.5f,-0.5f,-0.5f,
            -0.5f,0.5f,-0.5f,
            0.5f,0.5f,-0.5f,//face 2
     
            0.5f,0.5f,0.5f,
            0.5f,-0.5f,0.5f,
            0.5f,-0.5f,-0.5f,
            0.5f,0.5f,-0.5f,//face 3                
     
            -0.5f,0.5f,0.5f,
            -0.5f,0.5f,-0.5f,
            -0.5f,-0.5f,-0.5f,
            -0.5f,-0.5f,0.5f,//face 4
     
            0.5f,0.5f,0.5f,
            0.5f,0.5f,-0.5f,
            -0.5f,0.5f,-0.5f,
            -0.5f,0.5f,0.5f,//face 5
     
            -0.5f,-0.5f,0.5f,
            -0.5f,-0.5f,-0.5f,
            0.5f,-0.5f,-0.5f,
            0.5f,-0.5f,0.5f//face 6     
     
        };

    now, i am changing z cords by:

    Code :
    for(int i=0;i<24;i++)
        vertices[i*3+2]*=10
    glDepthRange(0,10.0);

    Now, i am expecting that z cords will be mapped to -0.5 to 0.5 range due to glDepthRange call and i can see a proper cube, but it gives o/p as that of when i comment glDepthRange call above with distorted geometry.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    258
    I would assume depthrange would only work between the values of 0 - 1

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    It set the linear tranformation from NDC to the z-buffer - and yes it is in the range 0-1. Do not confuse this with near and far planes of the projection matrix.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Posts
    318
    Quote Originally Posted by tonyo_au View Post
    It set the linear tranformation from NDC to the z-buffer - and yes it is in the range 0-1. Do not confuse this with near and far planes of the projection matrix.
    How can i simulate the above effect? by giving coords > 1 i want to scale that to 0-1..

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    By definition NDC is in the range -1 to +1, the z value is thenglRangeDepth is applied; so you can't have a coordinate > 1.
    read this
    http://www.songho.ca/opengl/gl_transform.html

Similar Threads

  1. glDepthRange()
    By debinair in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-06-2014, 04:13 AM
  2. what is the use of glDepthRange function ?
    By vivek.narvekar in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-29-2012, 02:30 AM
  3. glDepthRange (4.2+) vs. glDepthRangedNV
    By cameni in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-20-2012, 07:25 PM
  4. glDepthRange problem
    By imported_Adrian in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-20-2003, 02:03 AM
  5. glDepthRange()
    By radde in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-24-2001, 08:48 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