2014-09-22 91 views
2

由於我安裝了Xcode 6.0.1,我的OpenGL ES 1圖層在任何模擬設備(以及真實硬件:帶有iOS 8的iPhone 4S)上都顯示錯誤 - 圖層大小和位置錯誤。OpenGL ES 1 + iOS 8 = layer.bounds搞砸了嗎?

更改glViewport參數沒有任何區別。我實際上可以評論它,它看起來是一樣的。

部分解決:

我檢查,然後選中「使用自動佈局」對話框,這樣的Xcode我的窗口更新到新版本的要求。現在在iPhone 4S上一切都看起來不錯,但其他設備上窗口的大小仍然很糟糕。

任何人都將OpenGL ES 1代碼更新爲新設備?

回答

0

我已經設法通過考慮[[UIScreen mainScreen] bounds].size取向依賴於iOS 8並以編程方式對視圖進行編碼這一事實來正確顯示渲染緩衝區。所以我的代表看起來是這樣的:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *) { 

CGRect screenBound = [[UIScreen mainScreen] bounds]; 
CGSize screenSize = screenBound.size; 

screenHeight = screenSize.height; 
screenWidth = screenSize.width; 

window = [[UIWindow alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)]; 
window.bounds = CGRectMake(0, 0, screenWidth, screenHeight); 

MainViewController = [[UIViewController alloc] init]; 

glView = [[EAGLView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)]; 
glView.bounds = CGRectMake(0, 0, screenWidth, screenHeight); 

MainViewController.view = glView; 

window.rootViewController = MainViewController; 
[window makeKeyAndVisible]; 

[glView setupGame]; 
[glView startAnimation]; 

return YES; 

} 
0

我有我的OpenGL ES 1應用程序的類似問題。 下面的代碼總是返回在人像模式中的渲染大小(shouldAutorotate是NO,那麼自動旋轉在我的應用程序禁用):

glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); 
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); 

但現在(的Xcode 6.0.1,iOS8上)這個大小取決於設備的方向。所以我得到了錯誤的渲染緩衝區大小。

「使用自動佈局」選中+取消選中沒有幫助我。

+0

我使用相同的代碼。在我的情況下,iPhone 4和iPhone 5上的所有方向都可以正常工作,但在6和6 Plus上,如果我以橫向模式啓動應用程序(報告錯誤?),它會變得混亂。也許嘗試啓動你的應用程序在肖像和負載把代碼旋轉它,如果你需要它? – Tom 2014-09-25 15:11:53

+0

我只在iPad Mini Retina上測試過它。剛剛向蘋果發送了一個請求。現在等待正式答覆... – NightRadio 2014-09-25 18:31:44

1

一個解決辦法可能是讓尺寸(寬&高度),並決定實際寬度取決於其尺寸更大這樣的事情:

CGRect screenBounds = [[UIScreen mainScreen] bounds]; 
float scale = [UIScreen mainScreen].scale; 
float width = screenBounds.size.width; 
float height = screenBounds.size.height; 

NSLog(@"scale: %f, width: %f, height: %f", scale, width, height); 

float w = width > height ? width : height; 

if (scale == 2.0f && w == 568.0f) { ...