glreadpixel()を使用して自分のゲームの画面をキャプチャしたい。 iosバージョン3.1.1の2g iphoneでもシミュレータ上で正常に動作します。 しかし、iosバージョン4.2.1のipadではそれはありません。私はこれに関する問題を知りに来た。特定のデバイス(ipad)上の上記のiOSバージョン4.0の場合 深度バッファをバインドし、アンチエイリアス技術を使用します。そして、フレームバッファからのデータをキャプチャするopenglのglreadpixel()を使用すると、デスティネーションバッファ内のすべて0が返されます...デプスバッファとアンチエイリアス技術を使用してglreadpixel()でデータを読み込めない問題
デプスバッファをフレームバッファにバインドしないと、 。
iが使用されるコードである: -
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];*/
glreadpixel()またはopegl ES内の他の同様の機能を使用しながら、アンチエイリアシングと深さ情報を含める方法を任意のアイデア?
よろしいです!それ以外の方法がある場合は、私に知らせてください。一方私は私の検索を続ける必要があります。 – Tornado