glFrustum

Started by
3 comments, last by Allebarde 22 years, 1 month ago
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!
Advertisement
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.
Re-Hi
I''m asking myself how did you calculate the zdistance = 10? With some trigonometry no?
But if zdistance > 10.0f (even 10.0001) i don''t see my triangle in the screen. why?
Thanks again
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.
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

This topic is closed to new replies.

Advertisement