Skip to content

Commit

Permalink
Update overlay when changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Aug 19, 2014
1 parent 81e58e0 commit 27a1f19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/video.cpp
Expand Up @@ -382,6 +382,14 @@ void CVideo::initSDL()
#endif
}

#ifdef SDL_GPU
void CVideo::update_overlay()
{
sdl::timage img(overlay_);
shader_.set_overlay(img);
}
#endif

CVideo::~CVideo()
{
LOG_DP << "calling SDL_Quit()\n";
Expand Down Expand Up @@ -431,6 +439,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();
}

void CVideo::clear_overlay_area(SDL_Rect area)
Expand All @@ -443,11 +452,13 @@ void CVideo::clear_overlay_area(SDL_Rect area)
pixels[index] = color;
}
}
update_overlay();
}

void CVideo::clear_overlay()
{
overlay_ = create_compatible_surface(overlay_, getx(), gety());
update_overlay();
}
#endif

Expand Down Expand Up @@ -607,8 +618,6 @@ void CVideo::flip()
return;
#ifdef SDL_GPU
assert(render_target_);
sdl::timage img(overlay_);
shader_.set_overlay(img);
GPU_Flip(render_target_);
#else
#if !SDL_VERSION_ATLEAST(2, 0, 0)
Expand Down
2 changes: 2 additions & 0 deletions src/video.hpp
Expand Up @@ -185,6 +185,8 @@ class CVideo : private boost::noncopyable {

void initSDL();
#ifdef SDL_GPU
void update_overlay();

sdl::shader_program shader_;
surface overlay_;
#endif
Expand Down

0 comments on commit 27a1f19

Please sign in to comment.