How can I increase distance (zfar/gluPerspective) where openGL stops drawing objects?

Oscar Foley picture Oscar Foley · Mar 14, 2011 · Viewed 7.8k times · Source

I am learning OpenGL and having a problem with gluPerspective. Here is the code I use in Init()

// Calculate The Aspect Ratio Of The Window
// The parameters are:
// (view angle, aspect ration of the width to the height, 
//  The closest distance to the camera before it clips, 
// FOV, Ratio,  The farthest distance before it stops drawing)
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.5f, 3000.0f);

My scene works right.. but as soon as I go a little bit away from my objects they dissapear (As the red balls in image). : Frustrum example Web where I took graph from

I understand that red balls are outside of view and won't be shown. So what I want is to increase the distance where it stops drawing. I tried increasing 3000.0f but is not working!.

    gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.5f, 3000000.0f);

So my question is : How can I increase distance where openGL stops drawing objects?

Some pics about the problem: Pic1 Pic2

Answer

Oscar Foley picture Oscar Foley · Mar 14, 2011

I figured out what was happening so I answer this myself to help other people in the future:

Changing zfar works ok. The problem I had was (not included in the question for simplification) was my skybox. Skybox was small and was hiding the objects with the sky. In pic2 is easy to see!

So if you have a similar problem just double check your skybox. If it were a zfar problem everthing should be black instead of having a sky texture!