#### Archived

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

# glFrustum

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

## 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 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 on other sites
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

##### Share on other sites
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 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

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632651
• Total Posts
3007648
• ### Who's Online (See full list)

There are no registered users currently online

×