{
w = impl->w;
h = impl->h;
+ for(std::vector<SurfaceData::Filter>::iterator i =
+ data.applied_filters.begin(); i != data.applied_filters.end();
+ i++)
+ impl->apply_filter(i->type, i->color);
}
}
-void Surface::apply_mask(Color color)
+void Surface::apply_filter(int filter, Color color)
{
-impl->apply_mask(color);
+impl->apply_filter(filter, color);
+
+SurfaceData::Filter apply_filter;
+apply_filter.type = filter;
+apply_filter.color = color;
+data.applied_filters.push_back(apply_filter);
}
Surface::~Surface()
void
apply_filter_to_surface(SDL_Surface* surface, int filter, Color color)
{
-if(filter == MASK_FILTER)
+if(filter == HORIZONTAL_FLIP_FILTER)
+ {
+ SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true);
+ SDL_BlitSurface(surface, NULL, sur_copy, NULL);
+ SDL_SetAlpha(sur_copy,0,0);
+
+ SDL_Rect src, dst;
+ src.y = dst.y = 0;
+ src.w = dst.w = 1;
+ src.h = dst.h = sur_copy->h;
+ for(int x = 0; x < sur_copy->w; x++)
+ {
+ src.x = x; dst.x = sur_copy->w-1 - x;
+ SDL_BlitSurface(sur_copy, &src, surface, &dst);
+ }
+
+ SDL_FreeSurface(sur_copy);
+ }
+else if(filter == MASK_FILTER)
{
SDL_Surface* sur_copy = sdl_surface_from_sdl_surface(surface, true);
int
SurfaceOpenGL::draw_stretched(float x, float y, int sw, int sh, Uint8 alpha, Uint32 effect)
{
- if(effect & SEMI_TRANSPARENT)
- alpha = 128;
-
float pw = power_of_two(sw);
float ph = power_of_two(sh);
}
void
-SurfaceOpenGL::apply_mask(Color color)
+SurfaceOpenGL::apply_filter(int filter, Color color)
{
- ::apply_filter_to_surface(sdl_surface, MASK_FILTER, color);
+ ::apply_filter_to_surface(sdl_surface, filter, color);
create_gl(sdl_surface,&gl_texture);
w = sdl_surface->w;
/* Create a Surface, make it using colorkey, blit surface into temp, apply alpha
to temp sur, blit the temp into the screen */
/* Note: this has to be done, since SDL doesn't allow to set alpha to surfaces that
- already have an alpha mask yet... */
+ already have an alpha mask, yet... */
SDL_Surface* sdl_surface_copy = SDL_CreateRGBSurface (sdl_surface->flags,
- sdl_surface->w, sdl_surface->h, sdl_surface->format->BitsPerPixel,
+ (int)w, (int)h, sdl_surface->format->BitsPerPixel,
sdl_surface->format->Rmask, sdl_surface->format->Gmask,
sdl_surface->format->Bmask,
0);
SDL_SetColorKey(sdl_surface_copy, SDL_SRCCOLORKEY, colorkey);
- SDL_BlitSurface(sdl_surface, NULL, sdl_surface_copy, NULL);
+ SDL_BlitSurface(sdl_surface, &src, sdl_surface_copy, NULL);
SDL_SetAlpha(sdl_surface_copy ,SDL_SRCALPHA,alpha);
int ret = SDL_BlitSurface(sdl_surface_copy, NULL, screen, &dest);
}
void
-SurfaceSDL::apply_mask(Color color)
+SurfaceSDL::apply_filter(int filter, Color color)
{
- ::apply_filter_to_surface(sdl_surface, MASK_FILTER, color);
+ ::apply_filter_to_surface(sdl_surface, filter, color);
w = sdl_surface->w;
h = sdl_surface->h;