出于某种原因,我的 OpenGL 应用程序在 ios6 4 英寸 Retina 模拟器中运行时获得了错误的 CAEAGLLayer 边界信息。
CAEAGLLayer 边界打印为
layer bounds are: (0.000000,0.000000), (320.000000,480.000000)
从此代码:
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
printf("layer bounds are: (%f,%f), (%f,%f)\n", eaglLayer.bounds.origin.x, eaglLayer.bounds.origin.y, eaglLayer.bounds.size.width, eaglLayer.bounds.size.height );
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context]) {
[self release];
return nil;
}
animationInterval = 1.0 / 60.0;
}
return self;
}
然后窗口内容向上移动,0,0 不再位于正确的位置。
任何人都知道为什么将 CAEAGLLayer 设置为不正确的宽度/高度?
谢谢