当未启用多次采样时,glReadPixel运行良好。但是当启用多重采样时,它会给出0x502 opengl错误并且不会捕获屏幕。经过一番研究后,它似乎与解析多样本缓冲区有关 - 'glResolveMultisampleFramebufferAPPLE'。但是我无法让它在'takeAsCGImage'方法中工作,如下所示
有人可以帮忙吗?
+(CGImageRef) takeAsCGImage
{
CCDirector *director = [CCDirector sharedDirector];
CGSize displaySize = [director displaySizeInPixels];
CGSize winSize = [director winSizeInPixels];
// Create buffer for pixels
GLuint bufferLength = displaySize.width * displaySize.height * 4;
GLubyte* buffer = (GLubyte*)malloc(bufferLength);
// Read Pixels from OpenGL
glReadPixels(0, 0, displaySize.width, displaySize.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
NSLog(@"opengl error 0x%x", glGetError());
谢谢, 简单