From d0c30c6ad63522ccebc5edbd1970a3f7a3bd6b55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boldizs=C3=A1r=20Lipka?= Date: Tue, 19 Aug 2014 02:44:25 +0200 Subject: [PATCH] Apply updated overlay instantenously. --- src/video.cpp | 13 ++++++++++--- src/video.hpp | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/video.cpp b/src/video.cpp index 223f512239db..f006ad377251 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -383,10 +383,17 @@ void CVideo::initSDL() } #ifdef SDL_GPU -void CVideo::update_overlay() +void CVideo::update_overlay(SDL_Rect *rect) { sdl::timage img(overlay_); shader_.set_overlay(img); + + // Re-render the appropriate screen area so that overlay change is visible + static sdl::timage empty(image::get_texture("images/misc/blank.png")); + SDL_Rect whole = sdl::create_rect(0, 0, overlay_->w, overlay_->h); + SDL_Rect *r = rect == NULL ? &whole : rect; + empty.set_scale(float(r->w) / empty.base_width(), float(r->h) / empty.base_height()); + draw_texture(empty, r->x, r->y); } #endif @@ -442,7 +449,7 @@ void CVideo::blit_to_overlay(surface surf, int x, int y) } SDL_Rect r = sdl::create_rect(x, y, surf->w, surf->h); SDL_BlitSurface(surf, NULL, overlay_, &r); - update_overlay(); + update_overlay(&r); } void CVideo::clear_overlay_area(SDL_Rect area) @@ -455,7 +462,7 @@ void CVideo::clear_overlay_area(SDL_Rect area) pixels[index] = color; } } - update_overlay(); + update_overlay(&area); } void CVideo::clear_overlay() diff --git a/src/video.hpp b/src/video.hpp index 2cbb348a42a9..940fc6d0f5bc 100644 --- a/src/video.hpp +++ b/src/video.hpp @@ -185,7 +185,7 @@ class CVideo : private boost::noncopyable { void initSDL(); #ifdef SDL_GPU - void update_overlay(); + void update_overlay(SDL_Rect *rect = NULL); sdl::shader_program shader_; surface overlay_;