Results 1 to 9 of 9

Thread: I don't think I fully understand the use of the coordinate system for opengl...

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    3

    I don't think I fully understand the use of the coordinate system for opengl...

    Whenever I draw points using glBegin(GL_POINTS) if the Z coord is > 1 or < 0 the point is not drawn. Can someone explain why it works that way? Or maybe supply a link that explains how to take advantage or the coordinate system.

    I was using DirectX before and when you put a point at 1.0f,1.0f,10.0f. Depending on where your camera and stuff is, the point shows up in expected place. But for opengl it seems that 1.0f is limit for all dimentions. What's the deal?

  2. #2
    Member Contributor
    Join Date
    Jul 2002
    Location
    Southampton, PA, USA
    Posts
    61

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    When you call gluPerspective(...), the last two arguments are the near and far clipping planes. Points won't be drawn if their Z values are outside of this range.

    Alternatively, you can use glFrustum(...) to accomplish the same job, but in a less intuitive fashion (IMO; You manually calculatethe FOV and aspect ratio).

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    3

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    You know what... I thought that was my problem. But my near is 3.0f and my far is 7.0f. And no matter what I change it to I get the same results.

    Is there any reason with these settings that I should be seeing the problem?

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    680

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    are you sure that the matrix modes are right?

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(...);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    gluLookAt(...);

    this should configure the view correctly.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    If your near is 3, far is 7, your near clip plane will be at -3, the far clip plane at -7. (Negative z goes into the screen by default) So... if you try to draw a point with a z of 10.0f with no other transformations, you will not only be drawing it in front of the near clip plane, but behind your camera. Try to do a glTranslate(0.0, 0.0, -cameraDistance); to move the "camera" back a bit.
    Deiussum
    Software Engineer and OpenGL enthusiast

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    3

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    hmmmmm... I tried modifiying everything listed above. Right now im drawing and X allong the 0.0f z axis and a mesh ball in the middle. Made the numbers greater and smaller and they didn't even look like they effect anything. the glLook does how ever give me different results. but i changed the near and far to all different numbers and nothing happens. Oh well... maybe it's my G-Card or maybe I should stick to DirectX.

    Thanks everyone for your help and i will keep monkeying around.

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    9

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    try doing spheres or other shapes instead of points, if it's near the edge of the clipping area you'll see part of the sphere gone.

  8. #8
    Senior Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    680

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    what about posting your code, or parts of it? if glPerspective does not affect anything, something has to be wrong with your program, and that should be fixed, as otherwise there's the danger of you sticking do directx and we surely would like to help preventing this.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,753

    Re: I don't think I fully understand the use of the coordinate system for opengl...

    Again, if you are putting something at z=0, you are not going to see it, since in a perspective matrix, you should have your near far plane >0. (As I stated in your previous example of 3 for the near plane, it will be at z=-3, so z=0 is still in front of the near clip plane and will not be displayed.

    Switch to D3D if you want, but you are going to run into these same problems. It uses matrices pretty much the same way as OpenGL.
    Deiussum
    Software Engineer and OpenGL enthusiast

Similar Threads

  1. Replies: 0
    Last Post: 12-09-2017, 06:43 PM
  2. opengl coordinate system
    By Registrar in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 02-11-2011, 02:23 AM
  3. Which 3D coordinate system OpenGL uses?
    By Javac in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-14-2003, 02:55 AM
  4. Replies: 4
    Last Post: 03-07-2002, 06:30 AM
  5. OpenGL coordinate system
    By KurtCob in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 10-04-2000, 07:58 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