Set Renderbuffer Width and Height (Open GL ES)

Posted by Josh Elsasser on Stack Overflow See other posts from Stack Overflow or by Josh Elsasser
Published on 2010-05-26T19:29:52Z Indexed on 2010/05/26 22:21 UTC
Read the original article Hit count: 258

Filed under:
|
|

I'm currently experiencing an issue with an Open GL ES renderbuffer where the backing and width are are both set to 15. Is there any way to set them to the width of 320 and 480? My project is built up on Apple's EAGLView class and ES1Renderer, but I've moved it from the app delegate to a controller. I also moved the CADisplayLink outside of it (I update my game logic with the timestamp from this)

Any help would be greatly appreciated.

I add the glview to the window as follows:

   CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
   [window addSubview:gameController.glview];
   [window makeKeyAndVisible];

I synthesize the controller and the glview within it. The EAGLView and Renderer are otherwise unmodified.

Renderer Initialization:

  // Get the layer
    CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;

    eaglLayer.opaque = TRUE;
    eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
                                    [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];

    renderer =  [[ES1Renderer alloc] init];

Render "resize from layer" Method

- (BOOL)resizeFromLayer:(CAEAGLLayer *)layer
{   
    // Allocate color buffer backing based on the current layer size
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
    [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:layer];
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
    glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);

   NSLog(@"Backing Width:%i and Height: %i", backingWidth, backingHeight);

    if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES)
    {
        NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES));
        return NO;
    }

return YES;

}

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c