4 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 #ifndef __SURFACE_HPP__
21 #define __SURFACE_HPP__
27 #include "math/vector.hpp"
28 #include "texture.hpp"
29 #include "video_systems.hpp"
32 * A rectangular image.
33 * The class basically holds a reference to a texture with additional UV
34 * coordinates that specify a rectangular area on this texture
48 Surface(const std::string& file) :
49 texture(texture_manager->get(file)),
50 x(0), y(0), w(0), h(0),
54 w = texture->get_image_width();
55 h = texture->get_image_height();
56 surface_data = new_surface_data(*this);
59 Surface(const std::string& file, int x, int y, int w, int h) :
60 texture(texture_manager->get(file)),
61 x(x), y(y), w(w), h(h),
65 surface_data = new_surface_data(*this);
68 Surface(const Surface& other) :
69 texture(other.texture),
70 x(other.x), y(other.y),
71 w(other.w), h(other.h),
75 surface_data = new_surface_data(*this);
80 free_surface_data(surface_data);
84 /** flip the surface horizontally */
90 bool get_flipx() const
95 const Surface& operator= (const Surface& other)
99 texture = other.texture;
107 Texture *get_texture() const
112 void *get_surface_data() const
127 int get_width() const
132 int get_height() const
137 Vector get_position() const
138 { return Vector(get_x(), get_y()); }
141 * returns a vector containing width and height
143 Vector get_size() const
144 { return Vector(get_width(), get_height()); }