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());
谢谢,简单