我在一个世界中画我的三角形,三角形在背景中,但是当我在它后面的时候,三角形并不在前景中(正如它应该的那样)。
我在YouTube上放了一段视频,展示了有问题的here (确保你阅读了描述)
编辑:
//create instance of camera class
mainCamera = [[Camera alloc]init];
//Tell window to log mouse events
[[self window] setAcceptsMouseMovedEvents:YES];
//Timer for updating frames
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:1/30 target:self selector:@selector(redraw) userInfo:nil repeats:YES];
//keep timer running during event tracking
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSEventTrackingRunLoopMode];
[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSModalPanelRunLoopMode];
glEnable(GL_DEPTH_TEST);
glClearDepth(1.0f);
glShadeModel(GL_SMOOTH);
glEnable(GL_LINE_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//self in this case is my view. The code below is getting the size of the view.
gluPerspective(45.0f, [self frame].size.width / [self frame].size.height, 1.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
//creating triangle objects发布于 2011-11-14 08:16:01
你有没有用深度缓冲区创建你的上下文?
你用glEnable(GL_DEPTH_TEST);激活深度测试了吗?
您是否使用了适当的glDepthFunc深度测试?
https://stackoverflow.com/questions/8115897
复制相似问题