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