Update of /cvsroot/super-tux/supertux/lib/video
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5362/lib/video
Modified Files:
surface.h surface.cpp
Log Message:
Added filter to horizontal flip Surfaces.
Index: surface.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/video/surface.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- surface.h 27 Aug 2004 20:34:56 -0000 1.6
+++ surface.h 19 Oct 2004 17:45:38 -0000 1.7
@@ -59,7 +59,9 @@
/// types of filters
enum {
- MASK_FILTER
+ HORIZONTAL_FLIP_FILTER,
+ MASK_FILTER,
+ NONE_FILTER
};
/** This class holds all the data necessary to construct a surface */
@@ -118,7 +120,7 @@
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
@@ -146,7 +148,7 @@
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
@@ -162,7 +164,7 @@
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
@@ -183,7 +185,7 @@
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);
Index: surface.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/lib/video/surface.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- surface.cpp 16 Sep 2004 11:26:14 -0000 1.10
+++ surface.cpp 19 Oct 2004 17:45:38 -0000 1.11
@@ -197,9 +197,9 @@
}
}
-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()
@@ -255,7 +255,25 @@
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);
@@ -841,9 +859,9 @@
}
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;
@@ -1053,9 +1071,9 @@
}
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;
|