Skip to content

anonymous /gist:1340465
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
- (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!");
}
glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer);
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);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) {
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
Something went wrong with that request. Please try again.