Antkeeper  0.0.1
sdl-window.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_HPP
21 #define ANTKEEPER_APP_SDL_WINDOW_HPP
22 
23 #include <engine/app/window.hpp>
24 #include <SDL2/SDL.h>
25 #include <memory>
26 
27 namespace app {
28 
32 class sdl_window: public window
33 {
34 public:
36  (
37  const std::string& title,
38  const math::ivec2& windowed_position,
39  const math::ivec2& windowed_size,
40  bool maximized,
41  bool fullscreen,
42  bool v_sync
43  );
44 
45  sdl_window(const sdl_window&) = delete;
46  sdl_window(sdl_window&&) = delete;
47  sdl_window& operator=(const sdl_window&) = delete;
49 
50  virtual ~sdl_window();
51  void set_title(const std::string& title) override;
52  void set_position(const math::ivec2& position) override;
53  void set_size(const math::ivec2& size) override;
54  void set_minimum_size(const math::ivec2& size) override;
55  void set_maximum_size(const math::ivec2& size) override;
56  void set_maximized(bool maximized) override;
57  void set_fullscreen(bool fullscreen) override;
58  void set_v_sync(bool v_sync) override;
59  void make_current() override;
60  void swap_buffers() override;
61 
62  [[nodiscard]] inline const gl::pipeline& get_graphics_pipeline() const noexcept override
63  {
64  return *m_graphics_pipeline;
65  }
66 
67  [[nodiscard]] inline gl::pipeline& get_graphics_pipeline() noexcept override
68  {
69  return *m_graphics_pipeline;
70  }
71 
72 private:
73  friend class sdl_window_manager;
74 
75  SDL_Window* m_internal_window;
76  SDL_GLContext m_internal_context;
77  std::unique_ptr<gl::pipeline> m_graphics_pipeline;
78 };
79 
80 } // namespace app
81 
82 #endif // ANTKEEPER_APP_SDL_WINDOW_HPP
virtual ~sdl_window()
Definition: sdl-window.cpp:185
sdl_window & operator=(sdl_window &&)=delete
sdl_window(const std::string &title, const math::ivec2 &windowed_position, const math::ivec2 &windowed_size, bool maximized, bool fullscreen, bool v_sync)
Definition: sdl-window.cpp:30
void make_current() override
Makes the window's graphics context current.
Definition: sdl-window.cpp:286
void swap_buffers() override
Swaps the front and back buffers of the window's graphics context.
Definition: sdl-window.cpp:291
void set_v_sync(bool v_sync) override
Enables or disables v-sync.
Definition: sdl-window.cpp:245
gl::pipeline & get_graphics_pipeline() noexcept override
Returns the graphics pipeline associated with this window.
Definition: sdl-window.hpp:67
void set_title(const std::string &title) override
Changes the title of the window.
Definition: sdl-window.cpp:197
sdl_window(const sdl_window &)=delete
void set_position(const math::ivec2 &position) override
Changes the position of the window.
Definition: sdl-window.cpp:203
sdl_window(sdl_window &&)=delete
void set_maximized(bool maximized) override
Maximizes or unmaximizes the window.
Definition: sdl-window.cpp:225
const gl::pipeline & get_graphics_pipeline() const noexcept override
Returns the graphics pipeline associated with this window.
Definition: sdl-window.hpp:62
void set_fullscreen(bool fullscreen) override
Enables or disables fullscreen mode.
Definition: sdl-window.cpp:237
sdl_window & operator=(const sdl_window &)=delete
void set_minimum_size(const math::ivec2 &size) override
Sets the minimum size of the window.
Definition: sdl-window.cpp:213
void set_size(const math::ivec2 &size) override
Changes the size of the window.
Definition: sdl-window.cpp:208
void set_maximum_size(const math::ivec2 &size) override
Sets the maximum size of the window.
Definition: sdl-window.cpp:219
Graphics pipeline interface.
Definition: pipeline.hpp:48
n-dimensional vector.
Definition: vector.hpp:44