PDA

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



Matsy_2001
08-15-2003, 05:35 AM
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? http://www.opengl.org/discussion_boards/ubb/confused.gif

Jared@ETC
08-15-2003, 06:02 AM
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).

Matsy_2001
08-15-2003, 06:24 AM
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?

JanHH
08-15-2003, 09:08 AM
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.

Deiussum
08-15-2003, 09:14 AM
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.

Matsy_2001
08-15-2003, 02:50 PM
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.

adams_antics
08-15-2003, 03:11 PM
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.

JanHH
08-16-2003, 05:01 AM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif and we surely would like to help preventing this.

Deiussum
08-18-2003, 04:22 AM
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.