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)
6 #ifndef UNISON_VIDEO_BACKEND_RENDERER_HPP
7 #define UNISON_VIDEO_BACKEND_RENDERER_HPP
9 #include <unison/video/Coord.hpp>
29 /// Backend-specific renderer interface
38 /// Initialize the backend
39 virtual void init() = 0;
41 /// Cleanup the backend
42 virtual void quit() = 0;
44 /// Get the name of the renderer
45 /// \return the name of the renderer
46 virtual std::string get_name() = 0;
48 /// Check if the backend is usable
49 /// \return Whether the backend is usable
50 virtual bool is_usable() = 0;
52 virtual Surface load_surface(const std::string &filename) = 0;
53 virtual Surface load_surface(const std::string &filename, const Color &colorkey) = 0;
55 virtual void save_surface(const Surface &surface, const std::string &filename) = 0;
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;
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;
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;
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;
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;
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;