Archived

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

glFrustum

This topic is 5772 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I''m new here and i have a problem with glFrustum: glViewport(0,0,width,height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //gluPerspective(55.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glFrustum(-15.0f,15.0f,-15.0f,15.0f,0.0f,-20.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); I don''t understand why i don''t see anything. But using gluPerspective, I works Thanks for you help! (for a stupid question Bye!

Share this post


Link to post
Share on other sites
First error: You have the near Z plane at zero, which is bad (read forbidden).

If you want a similar FOV as with the gluProject command (55 degrees), you need to set the near Z plane at about 10.

Second error: You have the far Z plane at a negative distance. Both near and far Z must be positive.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ideally, the near clipping plane is the distance (in application units) between the viewport and the viewer, i.e. between the monitor and the user''s eyes.

A rough idea on how to estimate it.

Share this post


Link to post
Share on other sites
Does this help?
        
#define __PI (3.14159265358979323846264338327950288f)

#define __DEG2RAD (__PI/180)

#define deg2rad(x) ((x)*__DEG2RAD)

double aspect = (double) g_height/ (double) g_width;
double fovx = 80;
double rprojz = tan(deg2rad(fovx)*0.5);
glLoadIdentity();
//gluPerspective (80, g_width/g_height, 2, 600);

glFrustum(-rprojz, +rprojz, -aspect*rprojz, +aspect*rprojz, 1.0, 600.0f);


That'll give you nice perspective and you don't have to do any trig yourself...

Just change the width/height/fov at run time or compile time and volia....

Edited by - Spikeles on February 21, 2002 7:40:30 PM

Share this post


Link to post
Share on other sites