X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftexture.h;h=00ad954b8090d43cf018950fa3ed9832da488276;hb=157cef71aeb9ae25b7bb90f37dda11bc09329d11;hp=a80583dea13f8ecd87dc824d60d4781d7f3c8ed4;hpb=84160722392a024dda42bd86ca9bd85b68c49457;p=supertux.git diff --git a/src/texture.h b/src/texture.h index a80583dea..00ad954b8 100644 --- a/src/texture.h +++ b/src/texture.h @@ -29,6 +29,9 @@ #include #include "screen.h" +#include "vector.h" + +SDL_Surface* sdl_surface_from_sdl_surface(SDL_Surface* sdl_surf, int use_alpha); class SurfaceImpl; class SurfaceSDL; @@ -72,41 +75,60 @@ public: static Surfaces surfaces; public: static void reload_all(); + static void debug_check(); Surface(SDL_Surface* surf, int use_alpha); Surface(const std::string& file, int use_alpha); Surface(const std::string& file, int x, int y, int w, int h, int use_alpha); ~Surface(); + /** Captures the screen and returns it as Surface*, the user is expected to call the destructor. */ + static Surface* CaptureScreen(); + /** Reload the surface, which is necesarry in case of a mode swich */ void reload(); void draw(float x, float y, Uint8 alpha = 255, bool update = false); void draw_bg(Uint8 alpha = 255, bool update = false); void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha = 255, bool update = false); + void draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update = false); + void resize(int w_, int h_); + + /// conveniance function + void draw(const Vector& pos, Uint8 alpha = 255, bool update = false) + { + draw(pos.x, pos.y, alpha, update); + } }; /** Surface implementation, all implementation have to inherit from this class */ class SurfaceImpl { -public: +protected: SDL_Surface* sdl_surface; + +public: int w; int h; public: + SurfaceImpl(); + virtual ~SurfaceImpl(); + /** Return 0 on success, -2 if surface needs to be reloaded */ virtual int draw(float x, float y, Uint8 alpha, bool update) = 0; virtual int draw_bg(Uint8 alpha, bool update) = 0; virtual int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update) = 0; + virtual int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update) = 0; + int resize(int w_, int h_); + + SDL_Surface* get_sdl_surface() const; // @evil@ try to avoid this function }; class SurfaceSDL : public SurfaceImpl { public: - -public: SurfaceSDL(SDL_Surface* surf, int use_alpha); SurfaceSDL(const std::string& file, int use_alpha); SurfaceSDL(const std::string& file, int x, int y, int w, int h, int use_alpha); @@ -115,8 +137,10 @@ public: int draw(float x, float y, Uint8 alpha, bool update); int draw_bg(Uint8 alpha, bool update); int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update); + int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update); }; +#ifndef NOOPENGL class SurfaceOpenGL : public SurfaceImpl { public: @@ -131,10 +155,12 @@ public: int draw(float x, float y, Uint8 alpha, bool update); int draw_bg(Uint8 alpha, bool update); int draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update); + int draw_stretched(float x, float y, int w, int h, Uint8 alpha, bool update); private: void create_gl(SDL_Surface * surf, GLuint * tex); }; +#endif #endif /*SUPERTUX_TEXTURE_H*/