IOS 横向模式不工作 OPEN GL

标签 ios opengl-es-2.0

好吧,几乎所有的尝试都没有成功。

我需要我的引擎以 LandscapeRight 模式启动,因此我调用:

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

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

enter image description here

我设法通过使用旋转 View :

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

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

FrameBuffer: width: 960, height: 640

你仍然可以看到它不是 960x640,我不明白为什么?

enter image description here

最佳答案

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

首先将此 key 添加到您的 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 方面的更改。

关于IOS 横向模式不工作 OPEN GL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27776722/

相关文章:

iphone - UITableViewCell 重用和图像重新渲染

objective-c - 垃圾收集器销毁 Interface Builder 中的对象

ios - 点击文本字段、关闭键盘并再次点击文本字段时 UIWebView 崩溃

android - 从 NDK 中获取 SurfaceTexture 的 GL 上下文

opengl-es - GLSL低p : syntax error

ios - 带视频显示的平板电脑

iOS 如何在没有自动布局的情况下设置动态 tableview 单元格高度?

android - GL 最大纹理尺寸策略

opengl-es-2.0 - 等效于 OpenGL ES 2.0 的方法来 void glBindFragDataLocation(GLuint program, GLuint colorNumber, const char * name);

ios - 片段着色器未读取顶点着色器 'colorVarying' 的输出