我仍在学习如何使用 OpenGL,我想问是否有任何方法可以使用遮挡剔除对象后面的遮挡对象(相机不可见)。我使用截锥体剔除来检测不在相机视图内的对象。另外,我只想纯粹使用过剩。不想弄乱 ARB。任何提示都非常感谢
void render() {
glColor3f(0,1,0);
spheresTotal=0;
spheresDrawn=0;
for (int i = -3; i < 3; i+=4)
for(int k = -3; k < 3; k+=4) {
spheresTotal++;
Vec3 a(i,0,k);
if (!frustumOn || (frustum.sphereInFrustum(a,0.5) != FrustumG::OUTSIDE)) {
glPushMatrix();
glTranslatef(i,0,k);
glutWireSphere(0.5,5,5);
glPopMatrix();
spheresDrawn++;
}
}
}
此代码主要参考http://www.lighthouse3d.com/tutorials/view-frustum-culling/radar-approach-testing-points/。对于像我这样的初学者来说,这是一个很好的教程。