glCopyTexSubImage2D vs antialiasing on iPhone?
Trying to grab an antialiased framebuffer into a texture throws GL_INVALID_OPERATION (and turning off AA with no other changes works). Is there some trick to doing it?
(Jul 15, 2010 09:35 AM)Mark Levin Wrote: Trying to grab an antialiased framebuffer into a texture throws GL_INVALID_OPERATION (and turning off AA with no other changes works). Is there some trick to doing it?
Well I use glReadPixels to read my screen, and after I added AA I had to change my code because I couldn't read straight away from the "msaaFrameBuffer".
So before I read the Image I added:
Code:
- (void) prepareForPicture {
glBindFramebufferOES(GL_FRAMEBUFFER_OES, resolveFramebuffer);
}
What I do to read the Pixels of the screen
Code:
glReadPixels(1, 30, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pxlData);
CGColorSpaceRef colorSpace=CGColorSpaceCreateDeviceRGB();
CGContextRef context=CGBitmapContextCreate(pxlData, width, height, 8, width*sizeof(uint32_t), colorSpace, kCGImageAlphaNoneSkipLast);
//CGContextRef context=CGBitmapContextCreate(pxlData, 300, 300, 8, 300*sizeof(uint32_t), colorSpace, kCGImageAlphaLast);
CGImageRef image=CGBitmapContextCreateImage(context);
CGImageRef smallIm=[self resizeCGImage:image toWidth:96 andHeight:126];
UIImage *resultUIImage=[UIImage imageWithCGImage:smallIm];
You cannot read directly from a multisample renderbuffer. You must use ResolveFramebuffer() to produce a non-multisampled image first. This applies to both ReadPixels and CopyTexImage.
That being said, why are you using CopyTexImage instead of rendering directly to the texture?
That being said, why are you using CopyTexImage instead of rendering directly to the texture?
Thanks. This effect was a last-minute addition to the render pipeline that grabs the current screen image and transforms it (it's the zoom-and-blur effect when starting a fight in Warpgate). Seemed more efficient than repeating the entire render process, and it worked fine without AA.
(Jul 15, 2010 06:11 PM)Mark Levin Wrote: Seemed more efficient than repeating the entire render process, and it worked fine without AA.
Well even with rebinding the resolve-framebuffer you don't rerender everything. AFAIK bot the msaabuffer and the resolvebuffer still have their rendered data in ram, binding either just tells OpenGL where you want to read your pixels/image data.
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Antialiasing and NSOpenGLView attributes | Jar445 | 2 | 8,244 |
Jan 20, 2009 10:42 AM Last Post: maximile |
|
Trouble with glCopyTexSubImage2D when using multisampled rendering | TomorrowPlusX | 11 | 8,557 |
Nov 1, 2006 02:54 PM Last Post: OneSadCookie |
|
Quick question, will glCopyTexSubImage2D with with RECT textures? | TomorrowPlusX | 28 | 16,208 |
Jun 8, 2006 07:04 PM Last Post: akb825 |
|
antialiasing polygons | honkFactory | 37 | 25,716 |
Apr 3, 2006 09:19 AM Last Post: akb825 |
|
glCopyTexSubImage2D | pkraft | 3 | 5,349 |
Mar 8, 2005 01:59 PM Last Post: pkraft |