2 // C Interface: texture
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
9 // Copyright: See COPYING file that comes with this distribution
13 #ifndef SUPERTUX_TEXTURE_H
14 #define SUPERTUX_TEXTURE_H
19 #include <SDL_opengl.h>
26 /** Container class that holds a surface, necessary so that we can
27 switch Surface implementations (OpenGL, SDL) on the fly */
35 Surface(SDL_Surface* surf, int use_alpha);
36 Surface(const std::string& file, int use_alpha);
37 Surface(const std::string& file, int x, int y, int w, int h, int use_alpha);
40 void draw(float x, float y, Uint8 alpha = 255, bool update = false);
41 void draw_bg(Uint8 alpha = 255, bool update = false);
42 void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha = 255, bool update = false);
45 /** Surface implementation, all implementation have to inherit from
50 SDL_Surface* sdl_surface;
55 virtual void draw(float x, float y, Uint8 alpha, bool update) = 0;
56 virtual void draw_bg(Uint8 alpha, bool update) = 0;
57 virtual void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update) = 0;
60 class SurfaceSDL : public SurfaceImpl
65 SurfaceSDL(SDL_Surface* surf, int use_alpha);
66 SurfaceSDL(const std::string& file, int use_alpha);
67 SurfaceSDL(const std::string& file, int x, int y, int w, int h, int use_alpha);
68 virtual ~SurfaceSDL();
70 void draw(float x, float y, Uint8 alpha, bool update);
71 void draw_bg(Uint8 alpha, bool update);
72 void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update);
75 class SurfaceOpenGL : public SurfaceImpl
81 SurfaceOpenGL(SDL_Surface* surf, int use_alpha);
82 SurfaceOpenGL(const std::string& file, int use_alpha);
83 SurfaceOpenGL(const std::string& file, int x, int y, int w, int h, int use_alpha);
84 virtual ~SurfaceOpenGL();
86 void draw(float x, float y, Uint8 alpha, bool update);
87 void draw_bg(Uint8 alpha, bool update);
88 void draw_part(float sx, float sy, float x, float y, float w, float h, Uint8 alpha, bool update);
91 void create_gl(SDL_Surface * surf, GLuint * tex);
94 #endif /*SUPERTUX_TEXTURE_H*/
96 /* Local Variables: */