-class SurfaceOpenGL : public SurfaceImpl
-{
-public:
- GLuint gl_texture;
-
-public:
- SurfaceOpenGL(SDL_Surface* surf);
- SurfaceOpenGL(const std::string& file);
- SurfaceOpenGL(const std::string& file, int x, int y, int w, int h);
- SurfaceOpenGL(Color top_gradient, Color bottom_gradient, int w, int h);
-
- virtual ~SurfaceOpenGL();
-
- 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);
-
-private:
- void create_gl(SDL_Surface * surf, GLuint * tex);
+ Surface(const Surface& other) :
+ texture(other.texture),
+ x(other.x), y(other.y),
+ w(other.w), h(other.h),
+ flipx(false)
+ {
+ texture->ref();
+ surface_data = new_surface_data(*this);
+ }
+
+ ~Surface()
+ {
+ free_surface_data(surface_data);
+ texture->unref();
+ }
+
+ /** flip the surface horizontally */
+ void hflip()
+ {
+ flipx = !flipx;
+ }
+
+ bool get_flipx() const
+ {
+ return flipx;
+ }
+
+ const Surface& operator= (const Surface& other)
+ {
+ other.texture->ref();
+ texture->unref();
+ texture = other.texture;
+ x = other.x;
+ y = other.y;
+ w = other.w;
+ h = other.h;
+ return *this;
+ }
+
+ Texture *get_texture() const
+ {
+ return texture;
+ }
+
+ void *get_surface_data() const
+ {
+ return surface_data;
+ }
+
+ int get_x() const
+ {
+ return x;
+ }
+
+ int get_y() const
+ {
+ return y;
+ }
+
+ int get_width() const
+ {
+ return w;
+ }
+
+ int get_height() const
+ {
+ return h;
+ }
+
+ Vector get_position() const
+ { return Vector(get_x(), get_y()); }
+
+ /**
+ * returns a vector containing width and height
+ */
+ Vector get_size() const
+ { return Vector(get_width(), get_height()); }