summaryrefslogtreecommitdiffstats
path: root/src/game/client/io/video.hh
blob: 858983f7c21b9ef54f6d75fd765dbab9a6499aa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// SPDX-License-Identifier: BSD-2-Clause
// Copyright (c) 2025 Kirill Dmitrievich
// File: video.hh; Created: Tue Dec 30 2025 12:59:09
// Description: Video mode handling

#ifndef CLIENT_IO_VIDEO_HH
#define CLIENT_IO_VIDEO_HH
#pragma once

class VideoMode final {
public:
    constexpr explicit VideoMode(const GLFWvidmode& mode) noexcept;
    constexpr explicit VideoMode(int wide, int tall, int rate = GLFW_DONT_CARE) noexcept;

    constexpr int wide(void) const noexcept;
    constexpr int tall(void) const noexcept;
    constexpr int rate(void) const noexcept;

    constexpr bool operator==(const VideoMode& other) const noexcept;

private:
    int m_wide;
    int m_tall;
    int m_rate;
};

class FramebufferSizeEvent final {
public:
    constexpr explicit FramebufferSizeEvent(int wide, int tall) noexcept;
    constexpr int wide(void) const noexcept;
    constexpr int tall(void) const noexcept;

private:
    int m_wide;
    int m_tall;
};

namespace video
{
void init(void);
void init_late(void);
void shutdown(void);
void update(void);
void update_late(void);
} // namespace video

namespace video
{
void query_current_mode(int& wide, int& tall) noexcept;
void query_current_mode(int& wide, int& tall, bool& fullscreen) noexcept;
const std::vector<VideoMode>& query_fullscreen_modes(void) noexcept;
} // namespace video

namespace video
{
void request_fullscreen(int wide, int tall, int rate) noexcept;
void request_windowed(int wide, int tall) noexcept;
void request_windowed(void) noexcept;
} // namespace video

namespace video
{
void update_window_title(void);
} // namespace video

constexpr VideoMode::VideoMode(int wide, int tall, int rate) noexcept : m_wide(wide), m_tall(tall), m_rate(rate)
{
    // empty
}

constexpr VideoMode::VideoMode(const GLFWvidmode& mode) noexcept : m_wide(mode.width), m_tall(mode.height), m_rate(mode.refreshRate)
{
    // empty
}

constexpr int VideoMode::wide(void) const noexcept
{
    return m_wide;
}

constexpr int VideoMode::tall(void) const noexcept
{
    return m_tall;
}

constexpr int VideoMode::rate(void) const noexcept
{
    return m_rate;
}

constexpr bool VideoMode::operator==(const VideoMode& other) const noexcept
{
    auto result = true;
    result = result && (m_wide == other.m_wide || m_wide == GLFW_DONT_CARE || other.m_wide == GLFW_DONT_CARE);
    result = result && (m_tall == other.m_tall || m_tall == GLFW_DONT_CARE || other.m_tall == GLFW_DONT_CARE);
    result = result && (m_rate == other.m_rate || m_rate == GLFW_DONT_CARE || other.m_rate == GLFW_DONT_CARE);
    return result;
}

constexpr FramebufferSizeEvent::FramebufferSizeEvent(int wide, int tall) noexcept : m_wide(wide), m_tall(tall)
{
    // empty
}

constexpr int FramebufferSizeEvent::wide(void) const noexcept
{
    return m_wide;
}

constexpr int FramebufferSizeEvent::tall(void) const noexcept
{
    return m_tall;
}

#endif