Create a gist now

Instantly share code, notes, and snippets.

anonymous /gist:1340465
Created Nov 4, 2011

What would you like to do?
- (void) layoutSubviews
NSLog(@"Laying out subview");
[self destroyFramebuffer];
[self createFramebuffer];
[EAGLContext setCurrentContext:context];
if (needsErase) {
[self erase];
needsErase = NO;
- (BOOL) createFramebuffer
glGenFramebuffersOES(1, &viewFramebuffer);
glGenRenderbuffersOES(1, &viewRenderbuffer);
glBindFramebuffer(GL_FRAMEBUFFER_OES, viewFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER_OES, viewRenderbuffer);
CAEAGLLayer *eaglLayer = (CAEAGLLayer*)self.layer;
// This call associates the storage for the current render buffer with the EAGLDrawable (our CAEAGLLayer) allowing us to draw into a buffer that will later be rendered to the screen
BOOL status = [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:eaglLayer];
if (status == NO) {
NSLog(@"Failed to allocate renderbuffer storage!");
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth);
glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight);
// NSLog(@"Backing Width: %d Height: %d", backingWidth, backingHeight);
NSLog(@"Failed to make a complete framebuffer object %x", glCheckFramebufferStatus(GL_FRAMEBUFFER_OES));
return NO;
return YES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment