Initial integration, lots of broken stuff
[supertux.git] / src / unison / include / unison / video / backend / Renderer.hpp
1 //          Copyright Timothy Goya 2007.
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef UNISON_VIDEO_BACKEND_RENDERER_HPP
7 #define UNISON_VIDEO_BACKEND_RENDERER_HPP
8
9 #include <unison/video/Coord.hpp>
10
11 #include <string>
12 #include <istream>
13
14 namespace Unison
15 {
16    namespace Video
17    {
18       class Surface;
19       class Texture;
20       class Window;
21       class Color;
22       class Rect;
23       class RenderOptions;
24
25       namespace Backend
26       {
27          class Texture;
28          class Window;
29          /// Backend-specific renderer interface
30          class Renderer
31          {
32             public:
33                /// Destructor
34                virtual ~Renderer()
35                {
36                }
37
38                /// Initialize the backend
39                virtual void init() = 0;
40
41                /// Cleanup the backend
42                virtual void quit() = 0;
43
44                /// Get the name of the renderer
45                /// \return the name of the renderer
46                virtual std::string get_name() = 0;
47
48                /// Check if the backend is usable
49                /// \return Whether the backend is usable
50                virtual bool is_usable() = 0;
51
52                virtual Surface load_surface(const std::string &filename) = 0;
53                virtual Surface load_surface(const std::string &filename, const Color &colorkey) = 0;
54
55                virtual void save_surface(const Surface &surface, const std::string &filename) = 0;
56
57                /// Does a surface-to-surface blit
58                /// \param[in] src The source surface
59                /// \param[in] src_rect The part of the source surface to blit from
60                /// \param[in] dst The destination surface
61                /// \param[in] dst_pos The position to blit to
62                /// \param[in] options Extra blit options
63                virtual void blit(const Surface &src, const Rect &src_rect, Surface &dst, const Point &dst_pos, const RenderOptions &options) = 0;
64
65                /// Does a texture-to-surface blit
66                /// \param[in] src The source texture
67                /// \param[in] src_rect The part of the source texture to blit from
68                /// \param[in] dst The destination surface
69                /// \param[in] dst_pos The position to blit to
70                /// \param[in] options Extra blit options
71                virtual void blit(Texture *src, const Rect &src_rect, Surface &dst, const Point &dst_pos, const RenderOptions &options) = 0;
72
73                /// Fills a portion of a surface with the given color
74                /// \param[in] dst The destination surface
75                /// \param[in] color The color
76                /// \param[in] rect The portion to fill
77                virtual void fill(Surface &dst, const Color &color, const Rect &rect) = 0;
78
79                /// Fills with alpha blend a portion of a surface with the given color
80                /// \param[in] dst The destination surface
81                /// \param[in] color The color
82                /// \param[in] rect The portion to fill
83                virtual void fill_blend(Surface &dst, const Color &color, const Rect &rect) = 0;
84
85                /// Create a window
86                /// \param[in] size The size of the window
87                /// \param[in] logical_size The logical size of the window
88                /// \param[in] fullscreen Whether to open in fullscreen mode
89                /// \return The created window
90                virtual Window *create_window(const Area &size, const Area &logical_size, bool fullscreen) = 0;
91
92                /// Create a texture for the given surface
93                /// \param[in] surface The surface to convert
94                /// \param[in] name The name of the texture
95                /// \return The texture for the surface
96                virtual Texture *create_texture(const Surface &surface) = 0;
97          };
98       }
99    }
100 }
101
102 #endif