1
votes

I've noticed that the iPhone applications running on non-retina devices (iPad 2 and iPad Mini) are now by default rendered at iPhone Retina Graphics (2x) (If the Application has the retina assets).

Devices currently running iPhone Applications at Retina Graphics without a retina screen:

  • iPad 2
  • iPad Mini

There is now no Zoom option for non-retina devices running an iPhone application with retina graphics in the payload. This is great however I've been trying to get my Openframeworks iOS environment to work with with the new retina window and it is still rendering a non-retina OpenGL window (as the device itself is not a high dpi 2x scale).

Environments:


Current 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");

Main ViewController to run open (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; 

}

Anyone have any idea? I'm working on a few solutions may have a fix soon.

1

1 Answers

2
votes

Okay I found a solution before posting so going to put this up here for reference. :)

So when you create your main.mm, do not enable retina straight away. You need to wait until you have started the AppDelegate and let the native iOS core functions kick in.

So revised 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");
}

Revised GameViewController.mm (where I am instantiating the 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; 
}