supertux
video_system.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_VIDEO_SYSTEM_HPP
18 #define HEADER_SUPERTUX_VIDEO_VIDEO_SYSTEM_HPP
19 
20 #include <string>
21 #include <vector>
22 #include <SDL.h>
23 
24 #include "math/size.hpp"
25 #include "util/currenton.hpp"
26 #include "video/sampler.hpp"
27 #include "video/texture_ptr.hpp"
28 
29 class Rect;
30 class Renderer;
31 class SDLSurfacePtr;
32 class Sampler;
33 class Surface;
34 class SurfaceData;
35 class Viewport;
36 
37 class VideoSystem : public Currenton<VideoSystem>
38 {
39 public:
40  enum Enum {
41  VIDEO_AUTO,
42  VIDEO_OPENGL33CORE,
43  VIDEO_OPENGL20,
44  VIDEO_SDL,
45  VIDEO_NULL
46  };
47 
48  static std::unique_ptr<VideoSystem> create(VideoSystem::Enum video_system);
49 
50  static Enum get_video_system(const std::string &video);
51  static std::string get_video_string(Enum video);
52  static std::vector<std::string> get_available_video_systems();
53 
54 public:
55  VideoSystem() {}
56  ~VideoSystem() override {}
57 
59  virtual std::string get_name() const = 0;
60 
61  virtual Renderer* get_back_renderer() const = 0;
62  virtual Renderer& get_renderer() const = 0;
63  virtual Renderer& get_lightmap() const = 0;
64 
65  virtual TexturePtr new_texture(const SDL_Surface& image, const Sampler& sampler = Sampler()) = 0;
66 
67  virtual const Viewport& get_viewport() const = 0;
68  virtual void apply_config() = 0;
69  virtual void flip() = 0;
70  virtual void on_resize(int w, int h) = 0;
71  virtual Size get_window_size() const = 0;
72 
73  virtual void set_vsync(int mode) = 0;
74  virtual int get_vsync() const = 0;
75  virtual void set_gamma(float gamma) = 0;
76  virtual void set_title(const std::string& title) = 0;
77  virtual void set_icon(const SDL_Surface& icon) = 0;
78  virtual SDLSurfacePtr make_screenshot() = 0;
79 
80  void do_take_screenshot();
81 
82 private:
83  VideoSystem(const VideoSystem&) = delete;
84  VideoSystem& operator=(const VideoSystem&) = delete;
85 };
86 
87 #endif
88 
89 /* EOF */
Definition: renderer.hpp:30
A rectangular image.
Definition: surface.hpp:35
Definition: sampler.hpp:23
Definition: rect.hpp:30
Simple Wrapper class around SDL_Surface that provides exception safety.
Definition: sdl_surface_ptr.hpp:24
Definition: size.hpp:24
A &#39;Currenton&#39; allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
Definition: video_system.hpp:37
Definition: viewport.hpp:23
virtual std::string get_name() const =0
Return a human readable name of the current video system.