我不知道这是深度缓冲区问题还是其他问题。我可以看穿一堵墙,但看不到另一堵墙:
现在,当我旋转时,第二面墙变得更加突出:
我在 Interface Builder 中启用了深度缓冲区。我的 OGL 启用如下所示:
// enables
glEnable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
glEnable(GL_SMOOTH);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glEnable(GL_CULL_FACE);
//glCullFace(GL_BACK);
glFrontFace(GL_CCW);
//glDepthMask(GL_TRUE);
//glDepthFunc(GL_LESS);
有什么建议么。我注释掉了其他启用,因为它们似乎没有帮助。
根据要求,这是投影和模型视图设置:
// initialize all rotation matrices, translation matrix, and model view matrix to identity
rotateX = GLKMatrix4Identity;
rotateY = GLKMatrix4Identity;
rotateZ = GLKMatrix4Identity;
modelMat = GLKMatrix4Identity;
zNear = 0.1;
zFar = 1000.0;
frustumScale = 1.0;
//GLint maxbuffers;
//glGetIntegerv(GL_MAX_DRAW_BUFFERS, &maxbuffers);
//NSLog(@"Max. number of buffers: %d", maxbuffers);
// called?
NSLog(@"awakeFromNib called...");
// set the aspect ratio here
NSSize dim = [self frame].size;
aspectRatio = dim.width/dim.height;
// compute the projection matrix
projMat = GLKMatrix4MakePerspective(frustumScale, aspectRatio, zNear, zFar);
...
// compute the model matrix
GLKMatrix4 tempLeft = GLKMatrix4Multiply(rotateX, rotateY);
GLKMatrix4 tempRight = GLKMatrix4Multiply(rotateZ, translation);
modelMat = GLKMatrix4Multiply(tempLeft, tempRight);