适用于iPad2和iPad Mini的iOS iPhone应用程序运行iOS7 Retina图形

时间:2013-11-04 05:37:35

标签: ios iphone retina-display openframeworks

我注意到在非视网膜设备(iPad 2和iPad Mini)上运行的iPhone应用程序现在默认呈现在iPhone Retina Graphics(2x)(如果应用程序具有视网膜资产)。

目前在没有视网膜屏幕的Retina Graphics上运行iPhone应用程序的设备:

  • iPad 2
  • iPad Mini

对于运行带有视网膜图形的iPhone应用程序的非视网膜设备,现在没有“缩放”选项。 这很棒但是我一直试图让我的Openframeworks iOS环境与新的视网膜窗口一起工作,它仍然渲染非视网膜OpenGL窗口(因为设备本身不是高dpi 2倍规模)。

环境:


当前main.mm

ofAppiOSWindow * window = new ofAppiOSWindow();
NSInteger glViewW = [UIScreen mainScreen].bounds.size.height;
NSInteger glViewH = [UIScreen mainScreen].bounds.size.width;
// glViewW returns 768
// glViewH returns 1024

window->enableRendererES2();
// [UIScreen mainScreen] is used by enableRetina to check for scale dpi.
window->enableRetina();
window->enableDepthBuffer();


ofSetupOpenGL(ofPtr<ofAppBaseWindow>(window), 320, 480, OF_FULLSCREEN); 
window->startAppWithDelegate("AppDelegate");

主ViewController运行打开(GameViewController.mm)

- (BOOL)createGLView {
if(self.glView != nil) {
    return NO;
}

app = new GameEngineApp();
app->setDelegate(self);

NSInteger glViewW = [UIScreen mainScreen].bounds.size.height;
NSInteger glViewH = [UIScreen mainScreen].bounds.size.width;
// glViewW returns 320
// glViewH returns 480


CGRect glViewRect = CGRectMake(0, 0, glViewW, glViewH);

self.glView = [[[ofxiOSEAGLView alloc] initWithFrame:glViewRect
                                              andApp:app] autorelease];


self.glView.delegate = self;
self.glView.multipleTouchEnabled = NO;
[appContainer insertSubview:self.glView atIndex:0];
[self.glView layoutSubviews];
[self.glView setup];
[self.glView startAnimation];

return YES; 

}

任何人都有任何想法?我正在研究一些解决方案可能很快就会解决。

1 个答案:

答案 0 :(得分:2)

好的,我在发布之前找到了一个解决方案,所以请把它放在这里作为参考。 :)

因此,当您创建main.mm时,请勿立即启用视网膜。您需要等到启动AppDelegate并启动原生iOS核心功能。

修改后的Main.mm:

#include "ofMain.h"
#include "ofAppiOSWindow.h"

int main() {
    ofAppiOSWindow * window = new ofAppiOSWindow();
    window->enableRendererES2();
//-------------------------------------------------------------------------
    // --Disabled:-- window->enableRetina(); // delete / comment this line out here
//-------------------------------------------------------------------------
    window->enableDepthBuffer();
    // the below numbers will not effect the window size as this is done later
    ofSetupOpenGL(ofPtr<ofAppBaseWindow>(window), 320,480, OF_FULLSCREEN);
    window->startAppWithDelegate("AppDelegate");
}

修改了GameViewController.mm(我将实例化openFrameworks glView):

- (BOOL)createGLView {
    if(self.glView != nil) {
        return NO;
    }
    app = new GameEngineApp();
    app->setDelegate(self);


    NSInteger glViewW = [UIScreen mainScreen].bounds.size.height;
    NSInteger glViewH = [UIScreen mainScreen].bounds.size.width;
    CGRect glViewRect = CGRectMake(0, 0, glViewW, glViewH);
//-------------------------------------------------------------------------
    ofAppiOSWindow::getInstance()->enableRetina();  // <-- Enable retina here
//-------------------------------------------------------------------------
    self.glView = [[[ofxiOSEAGLView alloc] initWithFrame:glViewRect
                                                  andApp:app] autorelease];


    self.glView.delegate = self;
    self.glView.multipleTouchEnabled = NO;
    [appContainer insertSubview:self.glView atIndex:0];
    [self.glView layoutSubviews];
    [self.glView setup];
    [self.glView startAnimation];

    return YES; 
}