wren
Vulkan-based game engine
Loading...
Searching...
No Matches
window.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <SDL2/SDL.h>
4#include <SDL2/SDL_video.h>
5#include <spdlog/spdlog.h>
6
7#include <boost/describe/enum.hpp>
8#include <vulkan/vulkan.hpp>
10
11#include "event.hpp"
12
13namespace wren {
14
15DEFINE_ERROR("WindowErrors", WindowErrors, SDL_INIT, SDL_WINDOW,
16 SDL_VULKAN_EXTENSION);
17
18class Window {
19 public:
20 static auto create(const std::string &application_name) -> expected<Window>;
21
22 void shutdown();
23
24 auto create_surface(const ::vk::Instance &instance)
26
27 void dispatch_events(const event::Dispatcher &dispatcher);
28
29 [[nodiscard]] auto get_required_vulkan_extension() const
31
32 auto get_size() -> std::pair<int32_t, int32_t> {
33 int w = 0, h = 0;
34 SDL_GetWindowSize(window_, &w, &h);
35 return {w, h};
36 }
37
38 [[nodiscard]] auto native_handle() const { return window_; }
39
40 private:
41 explicit Window(SDL_Window *window) : window_(window) {}
42
43 SDL_Window *window_;
44};
45
46} // namespace wren
Definition window.hpp:18
auto get_size() -> std::pair< int32_t, int32_t >
Definition window.hpp:32
auto get_required_vulkan_extension() const -> expected< std::vector< std::string_view > >
Definition window.cpp:47
void dispatch_events(const event::Dispatcher &dispatcher)
Definition window.cpp:420
auto native_handle() const
Definition window.hpp:38
Window(SDL_Window *window)
Definition window.hpp:41
void shutdown()
Definition window.cpp:37
auto create_surface(const ::vk::Instance &instance) -> expected<::vk::SurfaceKHR >
Definition window.cpp:39
SDL_Window * window_
Definition window.hpp:43
static auto create(const std::string &application_name) -> expected< Window >
Definition window.cpp:18
Definition event.hpp:75
Definition editor_scene.hpp:5
std::expected< T, Err > expected
Definition result.hpp:49
#define DEFINE_ERROR(cat_name, name,...)
Definition result.hpp:88