Results 1 to 9 of 9

Thread: depth perception?

  1. #1
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    depth perception?

    I'm attempting to make a floor for my world, and as the floor (simply a square face) gets further away, one would assume that the sides would draw closer to each other. However, the face simply flattens out. How do I get it to accurately reflect depth? Pictures included in case I'm not making myself clear...

    pict1 - overhead view
    pict2 - camera raised up and moved back

    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: depth perception?

    Use gluPerspective( view_angle, hight/width ratio, near, far )
    Note near/far must be positive, near > 0.

    This will project depth, example even though the object is square, closer side will be larger then far side of square..


    Originally posted by Dogcow:
    I'm attempting to make a floor for my world, and as the floor (simply a square face) gets further away, one would assume that the sides would draw closer to each other. However, the face simply flattens out. How do I get it to accurately reflect depth? Pictures included in case I'm not making myself clear...

    pict1 - overhead view
    pict2 - camera raised up and moved back

    -Dogcow "moof!"
    Visit The Underground

  3. #3
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: depth perception?

    So would I use that instead of glOrtho or with it somehow?

    Thanks,
    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: depth perception?

    Yes, you can use it in place of glOrtho.

    But also you can draw using both, example would be drawing bitmaps which need no depth in ortho mode, then switch to perspective to draw 3D objects.

    See my examples on my website...
    http://www.angelfire.lycos.com/linux/nexusone

    Look at GLclock, comes with source code.

    Originally posted by Dogcow:
    So would I use that instead of glOrtho or with it somehow?

    Thanks,
    -Dogcow "moof!"
    Visit The Underground

  5. #5
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: depth perception?

    I tried numerous gluPerspective settings and none of them look any different.

    The first, gluPerspective(45,1,-10,10); resulted in this pict .

    The second, gluPerspective(85,9,-100,100); resulted in this pict .

    Why don't these look any different?

    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  6. #6
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: depth perception?

    If this helps more, here's the dimensions of the only object in my world:

    glVertex3f(-10.0f,0.0f,10.0f);
    glColor3f(1.0f,0.0f,0.0f);
    glVertex3f(10.0f,0.0f,10.0f);
    glColor3f(0.0f,1.0f,0.0f);
    glVertex3f(10.0f,0.0f,-10.0f);
    glColor3f(0.0f,0.0f,1.0f);
    glVertex3f(-10.0f,0.0f,-10.0f);

    My program starts out looking at:

    gluLookAt(0.0,5.0,-5.0,0.0,0.0,0.0,0.0,0.0,1.0);

    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: depth perception?

    The near clip plane must not be less than or equal to zero.

  8. #8
    Member Newbie
    Join Date
    Sep 2002
    Location
    Cookeville, TN, United States
    Posts
    36

    Re: depth perception?

    Hm, I changed it to a positive number and now can't get anything to show up... Any recommendations on some values to put to get it started?

    Thanks,
    -Dogcow "moof!"
    Visit The Underground
    -Dogcow "moof!"
    Visit The Underground

  9. #9
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: depth perception?

    The values depends on the scale of your scene. But you can always start with some absurd values, like set near to 0.0001 and far to 1000000. It will kill the depth buffer for sure, but you can change the values to fogure out what's best for you.

Similar Threads

  1. Convert GL_UNSIGNED_INT_24_8 packed depth stencil to float depth
    By RealtimeSlave in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-05-2017, 07:37 AM
  2. Linear interpolation of depth value between front and back face depth values
    By RealtimeSlave in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-16-2016, 05:39 AM
  3. OpenGL: Draw a depth texture to depth buffer
    By Balrog in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 04-25-2012, 04:53 AM
  4. glDrawPixels / writing depth values with depth function GL_LESS
    By flo in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 03-26-2003, 02:49 AM
  5. why depth buffer save to image file can not display depth information
    By victorswan in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-27-2001, 09:19 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