summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-25 10:57:56 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-25 10:57:56 -0500
commit367810f962951e6bc013f895023fa0487238c2cf (patch)
treedaed28d9a840ed4f60646c86420ff1154d03c9d6 /src
parente4251457fa46d22071c034e04d1f5ac53ba29593 (diff)
downloadtanetane-367810f962951e6bc013f895023fa0487238c2cf.tar.gz
tanetane-367810f962951e6bc013f895023fa0487238c2cf.tar.bz2
tanetane-367810f962951e6bc013f895023fa0487238c2cf.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/renderer.cpp11
1 files changed, 10 insertions, 1 deletions
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) {
228 SDL_RenderCopy(ren_.get(), canvas.get(), &cameraField, nullptr); 228 SDL_RenderCopy(ren_.get(), canvas.get(), &cameraField, nullptr);
229 229
230 if (game.getSystem<MessageSystem>().getCutsceneBarsProgress() > 0) { 230 if (game.getSystem<MessageSystem>().getCutsceneBarsProgress() > 0) {
231 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
231 SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_NONE); 232 SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_NONE);
232 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, 255); 233 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, 255);
233 234
@@ -248,6 +249,7 @@ void Renderer::render(Game& game) {
248 249
249 { 250 {
250 SDL_Rect destRect { 0, 111, 57, 13 }; 251 SDL_Rect destRect { 0, 111, 57, 13 };
252 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
251 SDL_RenderCopy(ren_.get(), textures_.at(speakerHeaderTex_).get(), nullptr, &destRect); 253 SDL_RenderCopy(ren_.get(), textures_.at(speakerHeaderTex_).get(), nullptr, &destRect);
252 } 254 }
253 255
@@ -262,6 +264,7 @@ void Renderer::render(Game& game) {
262 MESSAGE_TEXT_WIDTH, 264 MESSAGE_TEXT_WIDTH,
263 game.getFont().getCharacterHeight() }; 265 game.getFont().getCharacterHeight() };
264 266
267 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
265 SDL_RenderCopy(ren_.get(), speakerHeaderLine_.renderedTex.get(), nullptr, &destRect); 268 SDL_RenderCopy(ren_.get(), speakerHeaderLine_.renderedTex.get(), nullptr, &destRect);
266 } 269 }
267 } 270 }
@@ -285,6 +288,7 @@ void Renderer::render(Game& game) {
285 srcRect.w, 288 srcRect.w,
286 srcRect.h }; 289 srcRect.h };
287 290
291 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
288 SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect); 292 SDL_RenderCopy(ren_.get(), messageLines_[lineIndex].renderedTex.get(), &srcRect, &destRect);
289 } 293 }
290 294
@@ -294,6 +298,7 @@ void Renderer::render(Game& game) {
294 SDL_Rect srcRect { charLoc.x(), charLoc.y(), charSize.w(), charSize.h() }; 298 SDL_Rect srcRect { charLoc.x(), charLoc.y(), charSize.w(), charSize.h() };
295 SDL_Rect destRect { 13, 127 + 16 * lineIndex, charSize.w(), charSize.h() }; 299 SDL_Rect destRect { 13, 127 + 16 * lineIndex, charSize.w(), charSize.h() };
296 300
301 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
297 SDL_RenderCopy(ren_.get(), textures_.at(game.getFont().getTextureId()).get(), &srcRect, &destRect); 302 SDL_RenderCopy(ren_.get(), textures_.at(game.getFont().getTextureId()).get(), &srcRect, &destRect);
298 } 303 }
299 } 304 }
@@ -318,6 +323,7 @@ void Renderer::render(Game& game) {
318 8, 323 8,
319 8 }; 324 8 };
320 325
326 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
321 SDL_RenderCopy(ren_.get(), textures_.at(choiceArrowTex_).get(), nullptr, &destRect); 327 SDL_RenderCopy(ren_.get(), textures_.at(choiceArrowTex_).get(), nullptr, &destRect);
322 } else { 328 } else {
323 if (advMsgArrowTex_ == -1) { 329 if (advMsgArrowTex_ == -1) {
@@ -330,6 +336,7 @@ void Renderer::render(Game& game) {
330 8, 336 8,
331 8 }; 337 8 };
332 338
339 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
333 SDL_RenderCopy(ren_.get(), textures_.at(advMsgArrowTex_).get(), nullptr, &destRect); 340 SDL_RenderCopy(ren_.get(), textures_.at(advMsgArrowTex_).get(), nullptr, &destRect);
334 } 341 }
335 } 342 }
@@ -337,6 +344,7 @@ void Renderer::render(Game& game) {
337 } 344 }
338 345
339 if (effects.isScreenFaded()) { 346 if (effects.isScreenFaded()) {
347 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
340 SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_BLEND); 348 SDL_SetRenderDrawBlendMode(ren_.get(), SDL_BLENDMODE_BLEND);
341 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, effects.getScreenFadeProgress() * 255); 349 SDL_SetRenderDrawColor(ren_.get(), 0, 0, 0, effects.getScreenFadeProgress() * 255);
342 SDL_RenderFillRect(ren_.get(), nullptr); 350 SDL_RenderFillRect(ren_.get(), nullptr);
@@ -345,6 +353,7 @@ void Renderer::render(Game& game) {
345 if (game.getSystem<InputSystem>().isDebugConsoleOpen()) { 353 if (game.getSystem<InputSystem>().isDebugConsoleOpen()) {
346 // Not sure why I'm supposed to copy the cached texture to the screen 354 // Not sure why I'm supposed to copy the cached texture to the screen
347 // BEFORE rendering it, but we get flickering if we don't, so. 355 // BEFORE rendering it, but we get flickering if we don't, so.
356 SDL_SetRenderTarget(ren_.get(), cameraTex.get());
348 SDL_RenderCopy(ren_.get(), debugConsoleTex_.get(), nullptr, &debugDestRect_); 357 SDL_RenderCopy(ren_.get(), debugConsoleTex_.get(), nullptr, &debugDestRect_);
349 358
350 if (!debugConsoleTex_ || cachedDebugText_ != game.getSystem<InputSystem>().getDebugText()) { 359 if (!debugConsoleTex_ || cachedDebugText_ != game.getSystem<InputSystem>().getDebugText()) {
@@ -391,7 +400,7 @@ void Renderer::render(Game& game) {
391 SDL_RenderCopy(ren_.get(), textLines[i].get(), nullptr, &destRect); 400 SDL_RenderCopy(ren_.get(), textLines[i].get(), nullptr, &destRect);
392 } 401 }
393 402
394 SDL_SetRenderTarget(ren_.get(), nullptr); 403 //SDL_SetRenderTarget(ren_.get(), nullptr);
395 404
396 debugDestRect_ = SDL_Rect { 0, 0, CANVAS_WIDTH, height }; 405 debugDestRect_ = SDL_Rect { 0, 0, CANVAS_WIDTH, height };
397 } 406 }