Skip to content

Commit

Permalink
No need for that extra color renderbuffer in GPUImageFilter, since I'…
Browse files Browse the repository at this point in the history
…m rendering to a texture.
  • Loading branch information
BradLarson committed Feb 21, 2012
1 parent 260baa2 commit fdf06f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
16 changes: 2 additions & 14 deletions framework/Source/GPUImageFilter.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ @interface GPUImageFilter ()
GLint filterPositionAttribute, filterTextureCoordinateAttribute;
GLint filterInputTextureUniform, filterInputTextureUniform2;

GLuint filterRenderbuffer, filterFramebuffer;
GLuint filterFramebuffer;
}

// Managing the display FBOs
Expand Down Expand Up @@ -113,7 +113,6 @@ - (UIImage *)imageFromCurrentlyProcessedOutput;
CGSize currentFBOSize = [self sizeOfFBO];

NSUInteger totalBytesForImage = (int)currentFBOSize.width * (int)currentFBOSize.height * 4;
// GLubyte *rawImagePixels = (GLubyte *) calloc(totalBytesForImage, sizeof(GLubyte));
GLubyte *rawImagePixels = (GLubyte *)malloc(totalBytesForImage);
glReadPixels(0, 0, (int)currentFBOSize.width, (int)currentFBOSize.height, GL_RGBA, GL_UNSIGNED_BYTE, rawImagePixels);

Expand Down Expand Up @@ -166,18 +165,13 @@ - (void)createFilterFBO;
glGenFramebuffers(1, &filterFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, filterFramebuffer);

glGenRenderbuffers(1, &filterRenderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, filterRenderbuffer);

CGSize currentFBOSize = [self sizeOfFBO];
// NSLog(@"Filter size: %f, %f", currentFBOSize.width, currentFBOSize.height);

glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8_OES, (int)currentFBOSize.width, (int)currentFBOSize.height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, filterRenderbuffer);
glBindTexture(GL_TEXTURE_2D, outputTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (int)currentFBOSize.width, (int)currentFBOSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, outputTexture, 0);
// NSLog(@"GL error15: %d", glGetError());

GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

Expand All @@ -190,13 +184,7 @@ - (void)destroyFilterFBO;
{
glDeleteFramebuffers(1, &filterFramebuffer);
filterFramebuffer = 0;
}

if (filterRenderbuffer)
{
glDeleteRenderbuffers(1, &filterRenderbuffer);
filterRenderbuffer = 0;
}
}
}

- (void)setFilterFBO;
Expand Down
1 change: 0 additions & 1 deletion framework/Source/GPUImageOutput.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ - (void)dealloc
{
[self removeAllTargets];
[self deleteOutputTexture];

}

#pragma mark -
Expand Down

0 comments on commit fdf06f0

Please sign in to comment.