neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
gradient.hpp
Go to the documentation of this file.
1
// gradient.hpp
2
/*
3
neogfx C++ App/Game Engine
4
Copyright (c) 2018, 2020 Leigh Johnston. All Rights Reserved.
5
6
This program is free software: you can redistribute it and / or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation, either version 3 of the License, or
9
(at your option) any later version.
10
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
GNU General Public License for more details.
15
16
You should have received a copy of the GNU General Public License
17
along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <
neogfx/neogfx.hpp
>
23
#include <
neolib/core/uuid.hpp
>
24
#include <
neolib/core/string.hpp
>
25
26
namespace
neogfx::game
27
{
28
struct
gradient
29
{
30
neolib::cookie_ref_ptr
id
;
31
std::optional<aabb_2d>
boundingBox
;
32
33
struct
meta
:
i_component_data::meta
34
{
35
static
const
neolib::uuid
&
id
()
36
{
37
static
const
neolib::uuid
sId = { 0x7056b018, 0x15a1, 0x4bb1, 0x8b32, { 0xa2, 0x2e, 0x2a, 0x9f, 0xb7, 0xe7 } };
38
return
sId;
39
}
40
static
const
i_string
&
name
()
41
{
42
static
const
string
sName =
"Gradient"
;
43
return
sName;
44
}
45
static
uint32_t
field_count
()
46
{
47
return
2;
48
}
49
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
50
{
51
switch
(aFieldIndex)
52
{
53
case
0:
54
return
component_data_field_type::Id;
55
case
1:
56
return
component_data_field_type::Aabb2d | component_data_field_type::Optional;
57
default
:
58
throw
invalid_field_index
();
59
}
60
}
61
static
neolib::uuid
field_type_id
(uint32_t aFieldIndex)
62
{
63
switch
(aFieldIndex)
64
{
65
case
0:
66
case
1:
67
return
neolib::uuid
{};
68
default
:
69
throw
invalid_field_index
();
70
}
71
}
72
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
73
{
74
static
const
string
sFieldNames[] =
75
{
76
"Id"
,
77
"Bounding Box"
78
};
79
return
sFieldNames[aFieldIndex];
80
}
81
};
82
};
83
84
inline
bool
batchable
(
const
gradient
& lhs,
const
gradient
& rhs)
85
{
86
return
lhs.
id
.cookie() == rhs.
id
.cookie() &&
87
lhs.
boundingBox
== rhs.
boundingBox
;
// todo: allow batching with different bounding boxes
88
}
89
}
neolib::i_string
Definition
i_string.hpp:49
neogfx::game
Definition
aabb_octree.hpp:31
neogfx::game::batchable
bool batchable(const filter &lhs, const filter &rhs)
Definition
filter.hpp:88
neolib::ecs::component_data_field_type
component_data_field_type
Definition
i_component_data.hpp:52
neolib::cookie_ref_ptr
basic_cookie_ref_ptr< cookie > cookie_ref_ptr
Definition
jar.hpp:732
neogfx.hpp
string.hpp
neogfx::game::gradient::meta
Definition
gradient.hpp:34
neogfx::game::gradient::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
gradient.hpp:72
neogfx::game::gradient::meta::field_count
static uint32_t field_count()
Definition
gradient.hpp:45
neogfx::game::gradient::meta::id
static const neolib::uuid & id()
Definition
gradient.hpp:35
neogfx::game::gradient::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
gradient.hpp:49
neogfx::game::gradient::meta::field_type_id
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition
gradient.hpp:61
neogfx::game::gradient::meta::name
static const i_string & name()
Definition
gradient.hpp:40
neogfx::game::gradient
Definition
gradient.hpp:29
neogfx::game::gradient::boundingBox
std::optional< aabb_2d > boundingBox
Definition
gradient.hpp:31
neogfx::game::gradient::id
neolib::cookie_ref_ptr id
Definition
gradient.hpp:30
neolib::ecs::i_component_data::meta::invalid_field_index
Definition
i_component_data.hpp:134
neolib::ecs::i_component_data::meta
Definition
i_component_data.hpp:133
neolib::uuid
Definition
uuid.hpp:51
uuid.hpp
include
neogfx
game
gradient.hpp
Generated by
1.9.8