Antkeeper  0.0.1
sdl-window-manager.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_APP_SDL_WINDOW_MANAGER_HPP
21 #define ANTKEEPER_APP_SDL_WINDOW_MANAGER_HPP
22 
24 #include <engine/app/display.hpp>
25 #include <SDL2/SDL.h>
26 #include <unordered_map>
27 #include <vector>
28 
29 namespace app {
30 
31 class sdl_window;
32 
37 {
38 public:
43 
47  ~sdl_window_manager() override;
48 
49  void update() override;
50 
52  [[nodiscard]] std::shared_ptr<window> create_window
53  (
54  const std::string& title,
55  const math::ivec2& windowed_position,
56  const math::ivec2& windowed_size,
57  bool maximized,
58  bool fullscreen,
59  bool v_sync
60  ) override;
61 
62  [[nodiscard]] std::size_t get_display_count() const override;
63  [[nodiscard]] const display& get_display(std::size_t index) const override;
64 
65 private:
66  sdl_window* get_window(SDL_Window* internal_window);
67  void update_display(int sdl_display_index);
68 
69  std::vector<display> m_displays;
70  std::unordered_map<SDL_Window*, app::sdl_window*> m_window_map;
71 };
72 
73 } // namespace app
74 
75 #endif // ANTKEEPER_APP_SDL_WINDOW_MANAGER_HPP
Virtual display.
Definition: display.hpp:35
const display & get_display(std::size_t index) const override
Returns the display with the given index.
std::shared_ptr< window > create_window(const std::string &title, const math::ivec2 &windowed_position, const math::ivec2 &windowed_size, bool maximized, bool fullscreen, bool v_sync) override
std::size_t get_display_count() const override
Returns the number of available displays.
~sdl_window_manager() override
Destructs an SDL window manager.
sdl_window_manager()
Constructs an SDL window manager.
void update() override
Updates all managed windows.
n-dimensional vector.
Definition: vector.hpp:44