1// SuperTux
2// Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
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_SDL_SDL_VIDEO_SYSTEM_HPP
18#define HEADER_SUPERTUX_VIDEO_SDL_SDL_VIDEO_SYSTEM_HPP
19
20#include <memory>
21#include <SDL.h>
22
23#include "math/size.hpp"
24#include "video/sdlbase_video_system.hpp"
25#include "video/viewport.hpp"
26
27class SDLScreenRenderer;
28class SDLTextureRenderer;
29class TextureManager;
30
31class SDLVideoSystem final : public SDLBaseVideoSystem
32{
33public:
34 SDLVideoSystem();
35 ~SDLVideoSystem();
36
37 virtual std::string get_name() const override;
38
39 virtual Renderer* get_back_renderer() const override { return nullptr; }
40 virtual Renderer& get_renderer() const override;
41 virtual Renderer& get_lightmap() const override;
42
43 virtual TexturePtr new_texture(const SDL_Surface& image, const Sampler& sampler) override;
44
45 virtual const Viewport& get_viewport() const override { return m_viewport; }
46 virtual void apply_config() override;
47 virtual void flip() override;
48
49 virtual void set_vsync(int mode) override;
50 virtual int get_vsync() const override;
51
52 virtual SDLSurfacePtr make_screenshot() override;
53
54private:
55 void create_window();
56
57private:
58 std::unique_ptr<SDL_Renderer, decltype(&SDL_DestroyRenderer)> m_sdl_renderer;
59 Viewport m_viewport;
60 std::unique_ptr<SDLScreenRenderer> m_renderer;
61 std::unique_ptr<SDLTextureRenderer> m_lightmap;
62 std::unique_ptr<TextureManager> m_texture_manager;
63
64private:
65 SDLVideoSystem(const SDLVideoSystem&) = delete;
66 SDLVideoSystem& operator=(const SDLVideoSystem&) = delete;
67};
68
69#endif
70
71/* EOF */
72