Clear intermediate texture before blitting.

This commit is contained in:
Christian Speckner 2019-12-10 18:07:40 +01:00
parent f6eb86b9bb
commit e3dc861932
3 changed files with 8 additions and 1 deletions

View File

@ -23,6 +23,7 @@
"tuple": "cpp", "tuple": "cpp",
"utility": "cpp", "utility": "cpp",
"*.tcc": "cpp", "*.tcc": "cpp",
"functional": "cpp" "functional": "cpp",
"iomanip": "cpp"
} }
} }

View File

@ -106,6 +106,8 @@ void HqBlitter::blitToIntermediate()
SDL_Rect r = mySrcRect; SDL_Rect r = mySrcRect;
r.x = r.y = 0; r.x = r.y = 0;
SDL_UpdateTexture(myIntermediateTexture, nullptr, myBlankBuffer.get(), 4 * myIntermediateRect.w);
SDL_SetRenderTarget(myFB.renderer(), myIntermediateTexture); SDL_SetRenderTarget(myFB.renderer(), myIntermediateTexture);
SDL_RenderCopy(myFB.renderer(), mySrcTexture, &r, &myIntermediateRect); SDL_RenderCopy(myFB.renderer(), mySrcTexture, &r, &myIntermediateRect);
@ -138,6 +140,9 @@ void HqBlitter::recreateTexturesIfNecessary()
mySrcTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format, mySrcTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format,
texAccess, mySrcRect.w, mySrcRect.h); texAccess, mySrcRect.w, mySrcRect.h);
myBlankBuffer = make_unique<uInt32[]>(4 * myIntermediateRect.w * myIntermediateRect.h);
memset(myBlankBuffer.get(), 0, 4 * myIntermediateRect.w * myIntermediateRect.h);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myAttributes.smoothing ? "1" : "0"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myAttributes.smoothing ? "1" : "0");
myIntermediateTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format, myIntermediateTexture = SDL_CreateTexture(myFB.renderer(), myFB.pixelFormat().format,

View File

@ -54,6 +54,7 @@ class HqBlitter : public Blitter {
bool myRecreateTextures; bool myRecreateTextures;
SDL_Surface* myStaticData; SDL_Surface* myStaticData;
unique_ptr<uInt32[]> myBlankBuffer;
FrameBufferSDL2& myFB; FrameBufferSDL2& myFB;