}
}
-void Surface::apply_mask(Color color)
+void Surface::apply_filter(int filter, Color color)
{
-impl->apply_mask(color);
+impl->apply_filter(filter, color);
}
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 - 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);
}
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;
}
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;
/// types of filters
enum {
- MASK_FILTER
+ HORIZONTAL_FLIP_FILTER,
+ MASK_FILTER,
+ NONE_FILTER
};
/** This class holds all the data necessary to construct a surface */
void resize(int widht, int height);
- void apply_mask(Color color);
+ void apply_filter(int filter, Color color = Color(0,0,0));
};
/** Surface implementation, all implementation have to inherit from
SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function
- virtual void apply_mask(Color color) = 0;
+ virtual void apply_filter(int filter, Color color = Color(0,0,0)) = 0;
};
class SurfaceSDL : public SurfaceImpl
int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
- void apply_mask(Color color);
+ void apply_filter(int filter, Color color);
};
#ifndef NOOPENGL
int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
- void apply_mask(Color color);
+ void apply_filter(int filter, Color color);
private:
void create_gl(SDL_Surface * surf, GLuint * tex);