gpt4 book ai didi

opengl - 如何增加 openGL 停止绘制对象的距离(zfar/gluPerspective)?

转载 作者:行者123 更新时间:2023-12-04 00:24:03 26 4
gpt4 key购买 nike

我正在学习 OpenGL,但在使用 gluPerspective 时遇到了问题。这是我在 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);

我的场景工作正常......但是一旦我离开我的物体一点点它们就会消失(就像图像中的红球一样)。 : Frustrum example
Web where I took graph from

我知道红球不在视野范围内,不会显示。所以我想要的是增加停止绘制的距离。我尝试增加 3000.0f 但不起作用!。
    gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.5f, 3000000.0f);

所以我的问题是: 如何增加openGL停止绘制对象的距离?

关于问题的一些图片:
Pic1
Pic2

最佳答案

我弄清楚发生了什么,所以我自己回答这个问题以在 future 帮助其他人:

更改 zfar 工作正常。我遇到的问题是(不包括在简化问题中)是我的天空盒。 Skybox很小,用天空隐藏物体。在pic2中很容易看到!

因此,如果您遇到类似问题,请仔细检查您的天空盒。如果这是一个 zfar 问题,一切都应该
是黑色而不是天空纹理!

关于opengl - 如何增加 openGL 停止绘制对象的距离(zfar/gluPerspective)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5300888/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com