且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在OpenGL中移动相机时出现毛刺

更新时间:2023-02-02 09:51:34

我的第一个猜测是浮点舍入错误。这可能导致你的四边形的坐标只是一点点,导致你看到的差距。为了验证这一点,你可能想尝试改变glClearColor(),并看看是否间隙改变颜色。

My first guess would be floating point rounding error. This could cause the co-ordinates for your quads to be just a little bit out, resulting in the gaps you see. to verify this, you might want to try changing glClearColor() and seeing if the gaps change colour with it.

一个解决方案是让瓷砖稍大。

One solution to this would be to make the tiles slightly larger. Only a very small increment is needed (like 0.0001f) to cover over this kind of error.

或者,您可以尝试使用顶点数组 VBO 存储您的地面网格(确保邻接的正方形共享顶点)。我希望这可以解决这个问题,但我不是100%肯定 - 它也应该更快地呈现。

Alternatively, you could try using a Vertex Array or a VBO to store your ground mesh (ensuring that adjoining squares share vertices). I'd expect this to fix the issue, but I'm not 100% sure - and it should also render faster.