- SDL_Surface* sdl_surface;
- unsigned gl_texture;
- int w;
- int h;
- } texture_type;
-
-void texture_setup(void);
-extern void (*texture_load) (texture_type* ptexture, const std::string& file, int use_alpha);
-extern void (*texture_load_part) (texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
-extern void (*texture_free) (texture_type* ptexture);
-extern void (*texture_draw) (texture_type* ptexture, float x, float y, bool update = false);
-extern void (*texture_draw_bg) (texture_type* ptexture, bool update = false);
-extern void (*texture_draw_part) (texture_type* ptexture, float sx, float sy, float x, float y, float w, float h, bool update = false);
-void texture_load_sdl(texture_type* ptexture, const std::string&, int use_alpha);
-void texture_load_part_sdl(texture_type* ptexture, const std::string& file, int x, int y, int w, int h, int use_alpha);
-void texture_free_sdl(texture_type* ptexture);
-void texture_draw_sdl(texture_type* ptexture, float x, float y, bool update);
-void texture_draw_bg_sdl(texture_type* ptexture, bool update);
-void texture_draw_part_sdl(texture_type* ptexture,float sx, float sy, float x, float y, float w, float h, bool update);
-void texture_from_sdl_surface(texture_type* ptexture, SDL_Surface * sdl_surf, int use_alpha);
+ draw(pos.x, pos.y, alpha, update);
+ }
+};
+
+/** Surface implementation, all implementation have to inherit from
+ this class */
+class SurfaceImpl
+{
+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:
+ 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);
+ virtual ~SurfaceSDL();
+
+ 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);
+};
+