glFrustum Frustrations

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

glFrustum Frustrations

Postby seed » Fri Mar 19, 2010 4:05 pm

Sorry, this is a cross post. I didn't realize people post questions here as well as tutorials. Getting on with it.

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;
  2.  
  3. float zfrustum = 6;     // Made this large for deep perspective
  4.  
  5. float zeye = zfrustum;
  6.  
  7. float far = zfrustum * 2;
  8.  
  9. gl.glFrustum(-ratio,ratio,-1,1,z1,far);
  10.  
  11. glu.gluLookAt( 0,0,z2, 0,0,0, 0,1,0);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4

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:)

I am trying to make a game with a very specific and unchanging portal into the game world. Thus the concern that I line objects up exactly to the screen.

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

Top

Postby seed » Wed Mar 31, 2010 5:08 pm

BTW, this was a non-problem.

My appologies for the confused post. There was a model translation that was buried somewhere in some instance of some class that I didn't see that was screwing everything up. My bad.

regards, seed
seed
Senior Developer
Senior Developer
 
Posts: 103
Joined: Mon Mar 15, 2010 3:22 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 5 guests