make it possible to start supertux from top soruce directory
[supertux.git] / lib / video / surface.h
index ea9e694..2a27db8 100644 (file)
 
 #include "SDL.h"
 
-#include "math/vector.h"
-#include "video/screen.h"
+#include "../math/vector.h"
+#include "../video/screen.h"
 
 namespace SuperTux
   {
-  
+
+  void apply_filter_to_surface(SDL_Surface *surface, int filter, int value);
   SDL_Surface* sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, bool use_alpha);
   SDL_Surface* sdl_surface_from_nothing();
 
@@ -50,8 +51,17 @@ namespace SuperTux
     NONE_EFFECT       = 0x0000,
     /** Draw the Surface upside down */
     VERTICAL_FLIP     = 0x0001,
+    /** Draw the Surface from left to down */
+    HORIZONTAL_FLIP   = 0x0002,
     /** Draw the Surface with alpha equal to 128 */
-    SEMI_TRANSPARENT  = 0x0002
+    SEMI_TRANSPARENT  = 0x0004
+  };
+
+  /// types of filters
+  enum {
+    HORIZONTAL_FLIP_FILTER,
+    MASK_FILTER,
+    NONE_FILTER
   };
 
   /** This class holds all the data necessary to construct a surface */
@@ -62,6 +72,10 @@ namespace SuperTux
       ConstructorType type;
       SDL_Surface* surface;
       std::string file;
+
+      struct Filter { int type; Color color; };
+      std::vector<Filter> applied_filters;
+
       bool use_alpha;
       int x;
       int y;
@@ -109,6 +123,8 @@ namespace SuperTux
       void reload();
 
       void resize(int widht, int height);
+
+      void apply_filter(int filter, Color color = Color(0,0,0));
     };
 
   /** Surface implementation, all implementation have to inherit from
@@ -129,14 +145,14 @@ namespace SuperTux
       /** Return 0 on success, -2 if surface needs to be reloaded */
       virtual int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0;
       virtual int draw_part(float sx, float sy, float x, float y, float w, float h,  Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0;
-#if 0
+      virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0;
 
-      virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update) = 0;
-#endif
 
       int resize(int w_, int h_);
 
       SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function
+
+      virtual void apply_filter(int filter, Color color = Color(0,0,0)) = 0;
     };
 
   class SurfaceSDL : public SurfaceImpl
@@ -150,10 +166,9 @@ namespace SuperTux
 
       int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT);
       int draw_part(float sx, float sy, float x, float y, float w, float h,  Uint8 alpha, Uint32 effect = NONE_EFFECT);
-#if 0
+      int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
 
-      int draw_stretched(float x, float y, int w, int h, Uint8 alpha);
-#endif
+      void apply_filter(int filter, Color color);
     };
 
 #ifndef NOOPENGL
@@ -172,10 +187,9 @@ namespace SuperTux
 
       int draw(float x, float y, Uint8 alpha, Uint32 effect = NONE_EFFECT);
       int draw_part(float sx, float sy, float x, float y, float w, float h,  Uint8 alpha, Uint32 effect = NONE_EFFECT);
-#if 0
+      int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT);
 
-      int draw_stretched(float x, float y, int w, int h, Uint8 alpha);
-#endif
+      void apply_filter(int filter, Color color);
 
     private:
       void create_gl(SDL_Surface * surf, GLuint * tex);