我不知道这是否是深度缓冲问题。我可以通过一面墙看到而不是另一面墙:
现在当我旋转时,第二道墙变得更加突出:
我在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);
答案 0 :(得分:0)
解决了!!!!
通过Interface Builder设置深度缓冲区似乎无法正常工作。我不得不以编程方式设置它,问题就解决了。
NSOpenGLPixelFormatAttribute attribute[] = {NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24, 0};