Archived

This topic is now archived and is closed to further replies.

Dragn

gluPerspective() and perspective viewing volume

Recommended Posts

This is an introductory question regarding gluPerspective() and/or glFrustum(). Okay, Let''s say you call gluPerspective() with a fov angle of 60 degrees, an aspect ratio of 4/3, a near of 0.0, and a far of 100.0... e.g.,
  
glViewport(0, 0, fWidth, fHeight);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(60.0f, fWidth/fHeight, 0.0f, 100.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
  
The range of *visible* x and y coords changes, depending on the z-coord used...in other words, you can see more units on the x and y axises for an object which is "farther away", than for one that''s "closer". I need an algorithm where you can retrieve the viewable range of x-coords and y-coords, given a specific z-coord. In otherwords, retrieve the width and the height of the "frustum" at a given z-coord. This would allow me to tell if an object is visible to the user at certain x/y coords given the z-coord. I ought to be able to figure this out, but haven''t been able to yet. Any suggestions would be appreciated--or if there''s any major errors in my logic, I''d love to be corrected. Thanks Rob

Share this post


Link to post
Share on other sites