neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
material.hpp
Go to the documentation of this file.
1
// material.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
#include <
neogfx/gfx/color.hpp
>
26
#include <
neogfx/gfx/primitives.hpp
>
27
#include <
neogfx/gfx/image.hpp
>
28
#include <
neogfx/game/ecs_ids.hpp
>
29
#include <
neogfx/game/component.hpp
>
30
#include <
neogfx/game/color.hpp
>
31
#include <
neogfx/game/gradient.hpp
>
32
#include <
neogfx/game/texture.hpp
>
33
34
namespace
neogfx::game
35
{
36
struct
material
37
{
38
std::optional<color>
color
;
39
std::optional<gradient>
gradient
;
40
std::optional<shared<texture>>
sharedTexture
;
41
std::optional<texture>
texture
;
42
std::optional<shader_effect>
shaderEffect
;
43
bool
subpixel
;
44
45
struct
meta
:
i_component_data::meta
46
{
47
static
const
neolib::uuid
&
id
()
48
{
49
static
const
neolib::uuid
sId = { 0x5e04e3ad, 0xb4dd, 0x4bd2, 0x888d, { 0xaa, 0x58, 0xe9, 0x4f, 0x3a, 0x5e } };
50
return
sId;
51
}
52
static
const
i_string
&
name
()
53
{
54
static
const
string
sName =
"Material"
;
55
return
sName;
56
}
57
static
uint32_t
field_count
()
58
{
59
return
6;
60
}
61
static
component_data_field_type
field_type
(uint32_t aFieldIndex)
62
{
63
switch
(aFieldIndex)
64
{
65
case
0:
66
case
1:
67
return
component_data_field_type::ComponentData | component_data_field_type::Optional;
68
case
2:
69
return
component_data_field_type::ComponentData | component_data_field_type::Optional | component_data_field_type::Shared;
70
case
3:
71
return
component_data_field_type::ComponentData | component_data_field_type::Optional;
72
case
4:
73
return
component_data_field_type::Enum | component_data_field_type::Uint32 | component_data_field_type::Optional;
74
case
5:
75
return
component_data_field_type::Bool;
76
default
:
77
throw
invalid_field_index
();
78
}
79
}
80
static
neolib::uuid
field_type_id
(uint32_t aFieldIndex)
81
{
82
switch
(aFieldIndex)
83
{
84
case
0:
85
return
color::meta::id();
86
case
1:
87
return
gradient::meta::id
();
88
case
2:
89
case
3:
90
return
texture::meta::id
();
91
default
:
92
throw
invalid_field_index
();
93
}
94
}
95
static
const
i_string
&
field_name
(uint32_t aFieldIndex)
96
{
97
static
const
string
sFieldNames[] =
98
{
99
"Color"
,
100
"Gradient"
,
101
"Shared Texture"
,
102
"Texture"
,
103
"Shader Effect"
,
104
"Subpixel"
105
};
106
return
sFieldNames[aFieldIndex];
107
}
108
};
109
};
110
111
inline
bool
batchable
(
const
material
& lhs,
const
material
& rhs)
112
{
113
return
batchable
(lhs.
gradient
, rhs.
gradient
) &&
114
batchable
(lhs.
sharedTexture
, rhs.
sharedTexture
) &&
115
batchable
(lhs.
texture
, rhs.
texture
) &&
116
lhs.
shaderEffect
== rhs.
shaderEffect
&&
117
lhs.
subpixel
== rhs.
subpixel
;
118
}
119
}
neogfx::basic_gradient::id
gradient_id id() const override
neolib::i_string
Definition
i_string.hpp:49
color.hpp
gradient.hpp
texture.hpp
color.hpp
image.hpp
primitives.hpp
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
component.hpp
ecs_ids.hpp
neogfx.hpp
string.hpp
neogfx::game::material::meta
Definition
material.hpp:46
neogfx::game::material::meta::field_type_id
static neolib::uuid field_type_id(uint32_t aFieldIndex)
Definition
material.hpp:80
neogfx::game::material::meta::field_type
static component_data_field_type field_type(uint32_t aFieldIndex)
Definition
material.hpp:61
neogfx::game::material::meta::field_count
static uint32_t field_count()
Definition
material.hpp:57
neogfx::game::material::meta::name
static const i_string & name()
Definition
material.hpp:52
neogfx::game::material::meta::field_name
static const i_string & field_name(uint32_t aFieldIndex)
Definition
material.hpp:95
neogfx::game::material::meta::id
static const neolib::uuid & id()
Definition
material.hpp:47
neogfx::game::material
Definition
material.hpp:37
neogfx::game::material::color
std::optional< color > color
Definition
material.hpp:38
neogfx::game::material::subpixel
bool subpixel
Definition
material.hpp:43
neogfx::game::material::gradient
std::optional< gradient > gradient
Definition
material.hpp:39
neogfx::game::material::texture
std::optional< texture > texture
Definition
material.hpp:41
neogfx::game::material::sharedTexture
std::optional< shared< texture > > sharedTexture
Definition
material.hpp:40
neogfx::game::material::shaderEffect
std::optional< shader_effect > shaderEffect
Definition
material.hpp:42
neogfx::game::texture::meta::id
static const neolib::uuid & id()
Definition
texture.hpp:46
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
material.hpp
Generated by
1.9.8