IOS横向模式不工作OPEN GL

时间:2015-01-05 09:36:24

标签: ios opengl-es-2.0

好几乎尝试了所有事情,但没有用。

我需要我的引擎以LandscapeRight模式启动,因此我打电话:

//
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

问题在于其余部分根本没有旋转,

enter image description here

我设法使用以下方法旋转视图:

[pExternViewController setTransform:CGAffineTransformMakeRotation(M_PI/2.0f)];

但它没有按预期工作,帧缓冲区大小现在正确:

  

FrameBuffer:宽度:960,高度:640

你仍然可以看到它不是960x640,我无法弄清楚为什么?

enter image description here

1 个答案:

答案 0 :(得分:1)

好的,终于成功了。  enter image description here

首先将此密钥添加到plist文件(必需)

<key>UILaunchStoryboardName</key>
<string>Launch Screen</string>

屏幕尺寸定义

#define SCREEN_WIDTH (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height) : [[UIScreen mainScreen] bounds].size.width)

#define SCREEN_HEIGHT (IOS_VERSION_LOWER_THAN_8 ? (UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation) ? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width) : [[UIScreen mainScreen] bounds].size.height)

#define IOS_VERSION_LOWER_THAN_8 (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1)

窗口初始化

- (void) applicationDidFinishLaunching: (UIApplication*) application
{
    // Start in Landscape
    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];

    // Disable Auto Lock screen
    [[UIApplication sharedApplication] setIdleTimerDisabled: YES];

    // Set Bounds with the proper screen resolution
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    screenBounds        = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

    // Create window and view controler
    m_window            = [[UIWindow alloc] initWithFrame: screenBounds];
    m_window.backgroundColor = [UIColor redColor];

    // Create new view controller
    pExternViewController        =  [SvgzViewController alloc] ;

    // Initialize view controler with all pointers set up
    if( [pExternViewController initWithFrame: screenBounds ] == nil)
    {
        assert(!"Failed to initialize screen");
        exit(0);
    }

    // Rotate the window
    [m_window setTransform:CGAffineTransformMakeRotation(M_PI/2.0f)];

    // Set the proper window center after transformation
    m_window.center         = CGPointMake(screenBounds.size.height/2, screenBounds.size.width/2);

    // Add GL window
    [m_window addSubview: pExternViewController];

    //
    [m_window makeKeyAndVisible];

}

至少不需要通过这种方式完成GL方面的改变。