Skip to content

Commit

Permalink
Apply updated overlay instantenously.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Aug 19, 2014
1 parent f3e85e8 commit d0c30c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/video.cpp
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -455,7 +462,7 @@ void CVideo::clear_overlay_area(SDL_Rect area)
pixels[index] = color;
}
}
update_overlay();
update_overlay(&area);
}

void CVideo::clear_overlay()
Expand Down
2 changes: 1 addition & 1 deletion src/video.hpp
Expand Up @@ -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_;
Expand Down

0 comments on commit d0c30c6

Please sign in to comment.