3

I have a problem with openGL and orientation in my iPad app. The problem only happens with 4.3+ devices. It doesn't happen with 4.2 devices.

When I start the application with any orientation and draw, it draws correctly, but when I change the orientation, and try to draw, the iPad restarts itself. The restart happens on the call

[context presentRenderbuffer:GL_RENDERBUFFER_OES];

This is the code I use in layoutSubviews:

-(void) layoutSubviews {
    [EAGLContext setCurrentContext:context];

    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id<EAGLDrawable>) [self layer]];

    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);

    glScissor(0, 0, [self bounds].size.width, [self bounds].size.height);

    NSLog(@"%f -  %f", [self bounds].size.width, [self bounds].size.height);

    glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer);
    glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight);

    [self erase];
    [self drawExisting];

    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

My question is, did anything change is 4.3? I cant find anything that states that. Or if you see anything wrong in my code, please let me know.

Basel
  • 2,368
  • 1
  • 16
  • 21

1 Answers1

0

I solved this problem by destroying and then creating the buffer in layoutSubviews. This caused some new minor issues that I was able to fix. The destroy and create methods are from here: http://box2d.googlecode.com/.../Box2DView.mm

Basel
  • 2,368
  • 1
  • 16
  • 21