From 367810f962951e6bc013f895023fa0487238c2cf Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 25 Feb 2021 10:57:56 -0500 Subject: Fixed issue where debug console could be rendered onto message text In the renderer, it's important to set the render target properly before any copying or drawing operations, especially if it's after a call to renderMessageLine, since that changes the render target. --- src/renderer.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/renderer.cpp b/src/renderer.cpp index 3b2bd21..1196e50 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -228,6 +228,7 @@ void Renderer::render(Game& game) { SDL_RenderCopy(ren_.get(), canvas.get(), &cameraField, nullptr); if (game.getSystem().getCutsceneBarsProgress() > 0) { + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_NONE); SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, 255); @@ -248,6 +249,7 @@ void Renderer::render(Game& game) { { SDL_Rect destRect { 0, 111, 57, 13 }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), textures_.at(speakerHeaderTex_).get(), nullptr, &destRect); } @@ -262,6 +264,7 @@ void Renderer::render(Game& game) { MESSAGE_TEXT_WIDTH, game.getFont().getCharacterHeight() }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), speakerHeaderLine_.renderedTex.get(), nullptr, &destRect); } } @@ -285,6 +288,7 @@ void Renderer::render(Game& game) { srcRect.w, srcRect.h }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); } @@ -294,6 +298,7 @@ void Renderer::render(Game& game) { SDL_Rect srcRect { charLoc.x(), charLoc.y(), charSize.w(), charSize.h() }; SDL_Rect destRect { 13, 127 + 16 * lineIndex, charSize.w(), charSize.h() }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), textures_.at(game.getFont().getTextureId()).get(), &srcRect, &destRect); } } @@ -318,6 +323,7 @@ void Renderer::render(Game& game) { 8, 8 }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), textures_.at(choiceArrowTex_).get(), nullptr, &destRect); } else { if (advMsgArrowTex_ == -1) { @@ -330,6 +336,7 @@ void Renderer::render(Game& game) { 8, 8 }; + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), textures_.at(advMsgArrowTex_).get(), nullptr, &destRect); } } @@ -337,6 +344,7 @@ void Renderer::render(Game& game) { } if (effects.isScreenFaded()) { + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_BLEND); SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, effects.getScreenFadeProgress() * 255); SDL_RenderFillRect(ren_.get(), nullptr); @@ -345,6 +353,7 @@ void Renderer::render(Game& game) { if (game.getSystem().isDebugConsoleOpen()) { // Not sure why I'm supposed to copy the cached texture to the screen // BEFORE rendering it, but we get flickering if we don't, so. + SDL_SetRenderTarget(ren_.get(), cameraTex.get()); SDL_RenderCopy(ren_.get(), debugConsoleTex_.get(), nullptr, &debugDestRect_); if (!debugConsoleTex_ || cachedDebugText_ != game.getSystem().getDebugText()) { @@ -391,7 +400,7 @@ void Renderer::render(Game& game) { SDL_RenderCopy(ren_.get(), textLines[i].get(), nullptr, &destRect); } - SDL_SetRenderTarget(ren_.get(), nullptr); + //SDL_SetRenderTarget(ren_.get(), nullptr); debugDestRect_ = SDL_Rect { 0, 0, CANVAS_WIDTH, height }; } -- cgit 1.4.1