0

我不知道这是深度缓冲区问题还是其他问题。我可以看穿一堵墙,但看不到另一堵墙:

墙可见

现在,当我旋转时,第二面墙变得更加突出:

在此处输入图像描述

在此处输入图像描述

我在 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);
4

1 回答 1

0

解决了!!!!

通过 Interface Builder 设置深度缓冲区似乎不起作用。我必须以编程方式设置它,问题就解决了。

NSOpenGLPixelFormatAttribute attribute[] = {NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)24, 0};
于 2013-10-05T15:39:30.683 回答