colour.hpp

1
2
3
4
5
6
7
#pragma once


#include <vulkan/vulkan.h>


namespace planet::vk {

Linear colour format

The colours described by this time are intended for use as a linear colour space, so colour manipulation is a simple matter of multiplying the values. This should be the default when using the surface's best_format

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    struct colour {
        float r{}, g{}, b{}, a = {1};


        static colour const black, white;


        operator VkClearValue() const noexcept {
            VkClearValue c;
            c.color.float32[0] = r;
            c.color.float32[1] = g;
            c.color.float32[2] = b;
            c.color.float32[3] = a;
            return c;
        }

Multiple the RGB values

35
36
37
38
39
40
41
42
43
44
        friend colour operator*(colour const &c, float const m) noexcept {
            return {c.r * m, c.g * m, c.b * m, c.a};
        }
    };

    inline constexpr colour colour::black{};
    inline constexpr colour colour::white{1.0f, 1.0f, 1.0f};


}