X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=lib%2Fvideo%2Fsurface.h;h=069119562f7b59f2564f2cbd15c5413dc9a77170;hb=133d94d5b145f325c38c8c15c9ea561bfffb092d;hp=0d8983363eb80d085135297ade77d4e7934b14d7;hpb=aeef2a79fcf8061b5e947360b42695e0b8121fa6;p=supertux.git diff --git a/lib/video/surface.h b/lib/video/surface.h index 0d8983363..069119562 100644 --- a/lib/video/surface.h +++ b/lib/video/surface.h @@ -17,7 +17,6 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. - #ifndef SUPERTUX_TEXTURE_H #define SUPERTUX_TEXTURE_H @@ -25,17 +24,18 @@ #include #ifndef NOOPENGL -#include "SDL_opengl.h" +#include #endif #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 +50,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 +71,10 @@ namespace SuperTux ConstructorType type; SDL_Surface* surface; std::string file; + + struct Filter { int type; Color color; }; + std::vector applied_filters; + bool use_alpha; int x; int y; @@ -108,7 +121,7 @@ namespace SuperTux /** Reload the surface, which is necesarry in case of a mode swich */ 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 @@ -132,9 +145,9 @@ namespace SuperTux virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT) = 0; - 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 @@ -142,13 +155,15 @@ namespace SuperTux public: SurfaceSDL(SDL_Surface* surf, bool use_alpha); SurfaceSDL(const std::string& file, bool use_alpha); - SurfaceSDL(const std::string& file, int x, int y, int w, int h, bool use_alpha); + SurfaceSDL(const std::string& file, int x, int y, int w_, int h_, bool use_alpha); SurfaceSDL(Color top_gradient, Color bottom_gradient, int w, int h); virtual ~SurfaceSDL(); 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); int draw_stretched(float x, float y, int w, int h, Uint8 alpha, Uint32 effect = NONE_EFFECT); + + void apply_filter(int filter, Color color); }; #ifndef NOOPENGL @@ -169,6 +184,7 @@ namespace SuperTux 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_filter(int filter, Color color); private: void create_gl(SDL_Surface * surf, GLuint * tex);