2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "video/surface.hpp"
23 #include "video/texture.hpp"
24 #include "video/video_systems.hpp"
26 Surface::Surface(const std::string& file) :
27 texture(texture_manager->get(file)),
29 x(0), y(0), w(0), h(0),
33 w = texture->get_image_width();
34 h = texture->get_image_height();
35 surface_data = new_surface_data(*this);
38 Surface::Surface(const std::string& file, int x, int y, int w, int h) :
39 texture(texture_manager->get(file)),
41 x(x), y(y), w(w), h(h),
45 surface_data = new_surface_data(*this);
48 Surface::Surface(const Surface& other) :
49 texture(other.texture),
51 x(other.x), y(other.y),
52 w(other.w), h(other.h),
56 surface_data = new_surface_data(*this);
60 Surface::operator= (const Surface& other)
64 texture = other.texture;
74 free_surface_data(surface_data);
78 /** flip the surface horizontally */
84 bool Surface::get_flipx() const
90 Surface::get_texture() const
96 Surface::get_surface_data() const
102 Surface::get_x() const
108 Surface::get_y() const
114 Surface::get_width() const
120 Surface::get_height() const
126 Surface::get_position() const
128 return Vector(get_x(), get_y());
132 Surface::get_size() const
134 return Vector(get_width(), get_height());