Opengl es高分辨率iphone 4

问题描述:

我创建了一个空的iOS项目,然后添加了一个自定义的GLView类,然后将其添加到AppDelegate。我有以下问题:Opengl es高分辨率iphone 4

1)如何在iPhone 4上启用高分辨率视网膜模式?目前我使用下面的代码来检查设备:

CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease]; 
// Override point for customization after application launch. 
_view = [[GLView alloc] initWithFrame:screenBounds]; 
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
    NSLog(@"iPad detected"); 
} 
else { 
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) { 
     NSLog(@"iPhone4 detected"); 
     _view.contentScaleFactor = [[UIScreen mainScreen] scale]; 
    } 
    else { 
     NSLog(@"iPhone detected"); 
    } 
} 

self.window.backgroundColor = [UIColor whiteColor]; 
//self.window.rootViewController = [[[UIViewController alloc] initWithNibName:nil bundle:nil] autorelease]; 
[self.window addSubview:_view]; 

但它是借鉴与锯齿边缘的相当差质量的多边形甚至设置内容因素后如下图所示的图像:

http://farm8.staticflickr.com/7358/8725549609_e2ed1e0e2a_b.jpg

有没有办法将分辨率设置为960x640而不是默认的480x320?

请注意,我不能使用“[email protected]”,因为我在渲染缓冲区中运行时生成图像。

2)我有第二个问题是这样的警告消息:

"Application windows are expected to have a root view controller at the end of application launch" 

谢谢您的时间。

至于第一个问题,我不知道GLView初始化程序的管道,但内容比例必须在渲染缓冲区之前设置(通常在renderbufferStorage::方法之前)。要查看是否缓冲区的尺寸是否正确(应为960×640)的使用功能:

GLint width; 
glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &width) 

即使缓冲区是视网膜和尺寸正确的多边形可能仍然是参差不齐的,如果你不使用任何类型的反别名。在iOS中制作抗锯齿GL视图的最简单方法可能是多次采样,尝试搜索glResolveMultisampleFramebufferAPPLE()(尽管如此,您还需要多行几行)。