2013-05-10 95 views
1

我創建了一個空的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" 

謝謝您的時間。

回答

0

至於第一個問題,我不知道GLView初始化程序的管道,但內容比例必須在渲染緩衝區之前設置(通常在renderbufferStorage::方法之前)。要查看是否緩衝區的尺寸是否正確(應爲960×640)的使用功能:

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

即使緩衝區是視網膜和尺寸正確的多邊形可能仍然是參差不齊的,如果你不使用任何類型的反別名。在iOS中製作抗鋸齒GL視圖的最簡單方法可能是多次採樣,嘗試搜索glResolveMultisampleFramebufferAPPLE()(儘管如此,您還需要多行幾行)。