-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowConfig.cpp
More file actions
83 lines (71 loc) · 1.56 KB
/
Copy pathWindowConfig.cpp
File metadata and controls
83 lines (71 loc) · 1.56 KB
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
/**
*
* @file WindowConfig.cpp
* @author Gaspard Kirira
*
* Copyright 2026, Gaspard Kirira.
* All rights reserved.
* https://github.com/vixcpp/game
*
* Use of this source code is governed by a MIT license
* that can be found in the LICENSE file.
*
* Vix.cpp
*
*/
#include <vix/game/WindowConfig.hpp>
#include <utility>
#include <vix/game/GameError.hpp>
namespace vix::game
{
WindowConfig WindowConfig::defaults() noexcept
{
return WindowConfig{};
}
WindowConfig WindowConfig::headless_config() noexcept
{
WindowConfig config;
config.title = "Vix Game Headless";
config.width = 1;
config.height = 1;
config.fullscreen = false;
config.resizable = false;
config.visible = false;
config.vsync = false;
config.headless = true;
return config;
}
GameBoolResult WindowConfig::validate() const
{
if (title.empty())
{
return make_game_error(
GameErrorCode::InvalidArgument,
"window title cannot be empty");
}
if (!valid_size())
{
return make_game_error(
GameErrorCode::InvalidArgument,
"window size must be greater than zero");
}
return true;
}
WindowConfig &WindowConfig::set_title(std::string value)
{
title = std::move(value);
return *this;
}
WindowConfig &WindowConfig::set_size(
std::uint32_t w,
std::uint32_t h) noexcept
{
width = w;
height = h;
return *this;
}
bool WindowConfig::valid_size() const noexcept
{
return width > 0 && height > 0;
}
} // namespace vix::game