c5682f5e5109e122f01ab4ee2e297b39951ed4b1
[supertux.git] / src / unison / src / video / opengl / 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_OPENGL_RENDERER_HPP
7 #define UNISON_VIDEO_OPENGL_RENDERER_HPP
8
9 #include <unison/video/backend/Renderer.hpp>
10
11 #include <string>
12
13 #include "SDL.h"
14
15 namespace Unison
16 {
17    namespace Video
18    {
19       namespace Backend
20       {
21          class Texture;
22          class Window;
23       }
24       namespace OpenGL
25       {
26          /// Does rendering tasks like blits and color fills using OpenGL
27          class Renderer : public Backend::Renderer
28          {
29             public:
30                /// Default constructor
31                Renderer();
32
33                /// Destructor
34                ~Renderer();
35
36                /// Initialize the backend
37                void init();
38
39                /// Cleanup the backend
40                void quit();
41
42                /// Get the name of the renderer
43                /// \return the name of the renderer
44                std::string get_name();
45
46                /// Check if the backend is usable
47                /// \return Whether the backend is usable
48                bool is_usable();
49
50                Surface load_surface(const std::string &filename);
51                Surface load_surface(const std::string &filename, const Color &colorkey);
52                void save_surface(const Surface &surface, const std::string &filename);
53
54                /// Does a surface-to-surface blit
55                /// \param[in] src The source surface
56                /// \param[in] src_rect The part of the source surface to blit from
57                /// \param[in] dst The destination surface
58                /// \param[in] dst_pos The position to blit to
59                /// \param[in] options Extra blit options
60                void blit(const Surface &src, const Rect &src_rect, Surface &dst, const Point &dst_pos, const RenderOptions &options);
61
62                /// Does a texture-to-surface blit
63                /// \param[in] src The source texture
64                /// \param[in] src_rect The part of the source texture to blit from
65                /// \param[in] dst The destination surface
66                /// \param[in] dst_pos The position to blit to
67                /// \param[in] options Extra blit options
68                void blit(Backend::Texture *src, const Rect &src_rect, Surface &dst, const Point &dst_pos, const RenderOptions &options);
69
70                /// Fills a portion of a surface with the given color
71                /// \param[in] dst The destination surface
72                /// \param[in] color The color
73                /// \param[in] rect The portion to fill
74                void fill(Surface &dst, const Color &color, const Rect &rect);
75
76                /// Fills with alpha blend a portion of a surface with the given color
77                /// \param[in] dst The destination surface
78                /// \param[in] color The color
79                /// \param[in] rect The portion to fill
80                void fill_blend(Surface &dst, const Color &color, const Rect &rect);
81
82                /// Create a window
83                /// \param[in] size The size of the window
84                /// \param[in] logical_size The logical size of the window
85                /// \param[in] fullscreen Whether to open in fullscreen mode
86                /// \return The created window
87                Backend::Window *create_window(const Area &size, const Area &logical_size, bool fullscreen);
88
89                /// Create a texture for the given surface
90                /// \param[in] surface The surface to convert
91                /// \return The texture for the surface
92                Backend::Texture *create_texture(const Surface &surface);
93          };
94       }
95    }
96 }
97
98 #endif