Qt ライブラリを SDL アプリケーションと統合しようとしています。QPixmap を SDL_Surface に変換してから、そのサーフェスを表示したいと思います。これどうやってするの?私は良い例を見つけることができませんでした。
これまでに次のコードを管理しました。
Uint32 rmask = 0x000000ff;
Uint32 gmask = 0x0000ff00;
Uint32 bmask = 0x00ff0000;
Uint32 amask = 0xff000000;
SDL_FillRect(screen, NULL, SDL_MapRGBA(screen->format, 255, 255, 255, 255));
const QImage *qsurf = ...;
SDL_Surface *surf = SDL_CreateRGBSurfaceFrom((void*)qsurf->constBits(), qsurf->width(), qsurf->height(), 32, qsurf->width() * 4, rmask, gmask, bmask, amask);
SDL_BlitSurface(surf, NULL, screen, NULL);
SDL_FreeSurface(surf);
SDL_Flip(screen);
これは機能しますが、唯一の問題は、QImage ベースのサーフェスがペイントされるたびに、下にある領域がクリアされず、透明な部分が数フレームの間に「フェード」して固体になることです。
画面をSDL_FillRect
クリアすると想像できるものがありますが、そうではないようです。screen
プライマリ SDL サーフェスです。