2

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() または他の同様の関数を使用しているときに、アンチエイリアシングで深度情報を含める方法はありますか?

4

2 に答える 2

4

理解した!glReadPixels() を呼び出す前に、resolve-framebuffer を GL_FRAMEBUFFER にバインドする必要があります。

glBindFramebuffer(GL_FRAMEBUFFER, resolveFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, colorRenderbuffer);
glReadPixels(xpos, ypos, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixelByteArray);
glBindFramebuffer(GL_FRAMEBUFFER, sampleFrameBuffer);

次のフレームをレンダリングする前に、sample-framebuffer を GL_FRAMEBUFFER としてバインドしてください。ただし、デフォルトの Apple テンプレートでは既にこれが行われています。

于 2011-07-21T14:54:15.813 に答える
0

これで問題が解決するわけではありませんが、検索を調整するのに役立ちます。OpenGL- ESを使用しているためglReadPixels()、深度バッファを読み取ることができません。現在、アプリケーションで同じ機能の問題が発生しています。

于 2011-07-18T20:15:18.493 に答える