Use SCREEN_WIDTH/HEIGHT instead of SDL_RendererGetViewport(), as logical coordinates...
[supertux.git] / src / video / surface.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
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.
8 //
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.
13 //
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/>.
16
17 #ifndef HEADER_SUPERTUX_VIDEO_SURFACE_HPP
18 #define HEADER_SUPERTUX_VIDEO_SURFACE_HPP
19
20 #include <string>
21 #include <memory>
22
23 #include "math/vector.hpp"
24 #include "math/rect.hpp"
25 #include "video/surface_ptr.hpp"
26 #include "video/texture_ptr.hpp"
27
28 class SurfaceData;
29
30 /** A rectangular image.  The class basically holds a reference to a
31     texture with additional UV coordinates that specify a rectangular
32     area on this texture */
33 class Surface
34 {
35 public:
36   static SurfacePtr create(const std::string& file);
37   static SurfacePtr create(const std::string& file, const Rect& rect);
38
39 private:
40   TexturePtr texture;
41   SurfaceData* surface_data;
42   Rect rect;
43   bool flipx;
44
45 private:
46   Surface(const std::string& file);
47   Surface(const std::string& file, const Rect& rect);
48   Surface(const Surface&);
49
50 public:
51   ~Surface();
52
53   SurfacePtr clone() const;
54
55   /** flip the surface horizontally */
56   void hflip();
57   bool get_flipx() const;
58
59   TexturePtr get_texture() const;
60   SurfaceData* get_surface_data() const;
61   int get_x() const;
62   int get_y() const;
63   int get_width() const;
64   int get_height() const;
65   Vector get_position() const;
66
67   /** returns a vector containing width and height */
68   Vector get_size() const;
69
70 private:
71   Surface& operator=(const Surface&);
72 };
73
74 #endif
75
76 /* EOF */