OpenGl glFrustum frustrations

Put your problem here if it does not fit any of the other categories.

OpenGl glFrustum frustrations

Postby seed » Fri Mar 19, 2010 3:37 pm

Hey all.

I am trying to create a projection that makes the top edge of an object in my scene align to the top edge of the screen. The top edge of my object is y=1. I also want the near clipping plane to be the x,y plane. This seemed easy using glFrustum

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. float ratio = width/height;
  3. float zfrustum = 6;     // Made this large for deep perspective
  5. float zeye = zfrustum;
  7. float far = zfrustum * 2;
  9. gl.glFrustum(-ratio,ratio,-1,1,z1,far);
  11. glu.gluLookAt( 0,0,z2, 0,0,0, 0,1,0);
Parsed in 0.012 seconds, using GeSHi

I thought that as long as Z1=Z2 everything would by OK because I am putting the eye at the same distance as the length of the frustum. But it doesn't work. The camera is a little too far away. If I make zfrustrum smaller still keeping zeye equal to it, the camera gets farther away. What am I getting wrong?

I don't have the code here to try this, but on the drive in to my day job was imagining that maybe the near parameter in glFrustum is actually the distance to the near clipping plane on the hypotenose, but that doesn't match any tutorials I have seen. It would explain why longer values bring the camera closer though. Of course, this has to be wrong because the fuction is called glFrustum.

Thanks for any help.
Senior Developer
Senior Developer
Posts: 103
Joined: Mon Mar 15, 2010 3:22 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests