window.hpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
#pragma once


#include <planet/sdl/renderer.hpp>

#include <SDL.h>

#include <cstdint>


namespace planet::sdl {
    class init;
}


namespace planet::vk::sdl {

Vulkan Window

20
21
22
23
24
25
26
27
28
29
30
31
32
    class window final {
        planet::sdl::handle<SDL_Window, SDL_DestroyWindow> pw;
        affine::extents2d size;


      public:
        window(planet::sdl::init &,
               const char *name,
               std::size_t width,
               std::size_t height);
        window(planet::sdl::init &, const char *name, std::uint32_t flags = {});

        SDL_Window *get() const noexcept { return pw.get(); }

Refresh the window dimensions

36
        affine::extents2d const &refresh_window_dimensions();

Cached inner window size

40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        affine::extents2d const &extents() const noexcept { return size; }
        affine::rectangle2d rectangle() const noexcept {
            return {{0, 0}, size};
        }
        std::size_t uzwidth() const noexcept { return size.uzwidth(); }
        std::size_t uzheight() const noexcept { return size.uzheight(); }
        float width() const noexcept { return size.width; }
        float height() const noexcept { return size.height; }

        using constrained_type = ui::constrained2d<float>;
        constrained_type constraints() const noexcept {
            return {{size.width, 0, size.width}, {size.height, 0, size.height}};
        }
    };


}