如何增加openGL停止绘制对象的距离(zfar/gluPerspective)? [英] How can I increase distance (zfar/gluPerspective) where openGL stops drawing objects?
问题描述
我正在学习OpenGL,但gluPerspective有问题.这是我在Init()中使用的代码
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). : Web where I took graph from
我知道红球不在视野范围内,因此不会显示.所以我想要的是增加它停止绘制的距离.我尝试增加3000.0f,但不起作用!.
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);
所以我的问题是:如何增加openGL停止绘制对象的距离?
Some pics about the problem: Pic1 Pic2
推荐答案
我知道发生了什么事,所以我自己回答这个问题,以帮助将来的其他人:
I figured out what was happening so I answer this myself to help other people in the future:
更改zfar可以.我遇到的问题(为简化起见未包括在内)是我的天窗. Skybox很小,正在用天空隐藏物体.在pic2中很容易看到!
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!
因此,如果您遇到类似的问题,请仔细检查您的Skybox.如果这是一个zfar问题,那么一切都应该 是黑色而不是天空纹理!
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!
这篇关于如何增加openGL停止绘制对象的距离(zfar/gluPerspective)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!