Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I created an empty iOS project and then added a custom GLView class which is then added to AppDelegate. I have following questions:

1) How do I enable hi-res retina mode on iPhone 4? Currently I am using the following code to check for device. The following code is from the AppDelegate where it first allocates GLView and then sets contentScale.

CGRect screenBounds = [[UIScreen mainScreen] bounds];
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
// Override point for customization after application launch.
_view = [[GLView alloc] initWithFrame:screenBounds];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    NSLog(@"iPad detected");
}
else {
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) {
        NSLog(@"iPhone4 detected");
        _view.contentScaleFactor = [[UIScreen mainScreen] scale];
    }
    else {
        NSLog(@"iPhone detected");
    }
}

self.window.backgroundColor = [UIColor whiteColor];
//self.window.rootViewController = [[[UIViewController alloc] initWithNibName:nil bundle:nil] autorelease];
[self.window addSubview:_view];

But even after setting content factor it is drawing pretty poor quality polygons with jagged edges as shown in the image below:

http://farm8.staticflickr.com/7358/8725549609_e2ed1e0e2a_b.jpg

Is there any way to set the resolution to 960x640 instead of the default 480x320 ?

Please note that I can not use "someImage@2x.png" because I am generating images at runtime in the render buffer.

2) Second problem I am having is this warning message:

"Application windows are expected to have a root view controller at the end of application launch"

Thank you for your time.

Edit: Problem solved. Set contentScale before allocating render buffer memory, i.e: inside GLView, not AppDelegate.

share|improve this question
    
How are you setting up your GL renderbuffer and projection matrix? Specifically, does e.g. glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); get you a backingWidth at the higher resolution? –  leander May 10 '13 at 20:05
    
@leander : Well I had to set eaglLayer.contentScale in GLView instead of AppDelegate. That solved the problem. Thanks! –  fakhir May 11 '13 at 11:21
add comment

2 Answers 2

The warning you see is because you didn't add a view controller to your window. If your AppDelegate does the work of loading up the view, a view controller isn't necessary, however Apple recommends using them. It's not a critical warning.

I believe you need to set the content scale on both the backing EAGL layer and the view itself. UIView has the layer property, which you can cast to CAEAGLLayer. So after you set the content scale of your view, do something like this:

CAEAGLLayer *eaglLayer = (CAEAGLLayer *)_view.layer;
eaglLayer.contentsScale = 2.0f;
share|improve this answer
    
I added the lines of code as you mentioned, no difference in the output at all! Please download complete xcode project from this link: Xcode Project –  fakhir May 10 '13 at 23:18
    
"The file you're looking for has been deleted or moved." –  James A May 13 '13 at 16:25
    
also, if the answer you provided worked, you should click the check mark so others will know that it's been answered. –  James A May 13 '13 at 20:24
add comment

Set contentScale before allocating render buffer memory, i.e: inside GLView, not AppDelegate. I deleted the following code from AppDelegate and placed it into GLView:

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        NSLog(@"iPad detected");
    }
    else {
        if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) {
            NSLog(@"iPhone4 detected");
            eaglLayer.contentsScale = 2.0f;
        }
        else {
            NSLog(@"iPhone detected");
        }
    }

What happened before was that the GLView was being initialised just before setting new scale factor with AppDelegate.

If Apple is ok with the warning and will not reject the app due to this:

"Application windows are expected to have a root view controller at the end of application launch"

Then problem solved. Thanks a lot !

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.