glreadpixel() を使用してゲームの画面をキャプチャしたい。iOSバージョン3.1.1の2g iPhoneでもシミュレーターで正常に動作します。しかし、iOS バージョン 4.2.1 の iPad ではそうではありません。これに関する問題を知りました。上記の iOS バージョン 4.0 の特定のデバイス (iPad) では、深度バッファをバインドし、アンチエイリアシング技術を使用します。そして、フレームバッファからデータをキャプチャするopenglの glreadpixel() を使用すると、宛先バッファにすべて0が返されます...
深度バッファをフレーム バッファにバインドせず、アンチエイリアシング技術を使用しない場合、問題なく動作します。
私が使用したコードは次のとおりです:-
CGRect screenBounds = [[UIScreen mainScreen] 境界];
int backingWidth = screenBounds.size.width;
int backingHeight =screenBounds.size.height;
NSLog(@"width : %f Height : %f",screenBounds.size.width,screenBounds.size.height);
CGSize esize = CGSizeMake(screenBounds.size.width, screenBounds.size.height);
NSInteger myDataLength = esize.width * esize.height * 4;
GLuint *buffer = (GLuint *) malloc(myDataLength);
glReadPixels(0, 0, esize.width, esize.height, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
for(int y = 0; y < backingHeight / 2; y++) {
for(int xt = 0; xt < backingWidth; xt++) {
GLuint top = buffer[y * backingWidth + xt];
GLuint bottom = buffer[(backingHeight - 1 - y) * backingWidth + xt];
buffer[(backingHeight - 1 - y) * backingWidth + xt] = top;
buffer[y * backingWidth + xt] = bottom;
}
}
CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer, myDataLength, releaseScreenshotData);
const int bitsPerComponent = 8;
const int bitsPerPixel = 4 * bitsPerComponent;
const int bytesPerRow = 4 * backingWidth;
CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB();
CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault;
CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault;
CGImageRef imageRef = CGImageCreate(backingWidth,backingHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent);
CGColorSpaceRelease(colorSpaceRef);
CGDataProviderRelease(provider);
/*
UIImage *myImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
[snap setImage:myImage];
[self addSubview:snap];*/
opegl es で glreadpixel() または他の同様の関数を使用しているときに、アンチエイリアシングで深度情報を含める方法はありますか?