Visual Computing Library
Loading...
Searching...
No Matches
drawable_mesh_uniforms.h
1
/*****************************************************************************
2
* VCLib *
3
* Visual Computing Library *
4
* *
5
* Copyright(C) 2021-2025 *
6
* Visual Computing Lab *
7
* ISTI - Italian National Research Council *
8
* *
9
* All rights reserved. *
10
* *
11
* This program is free software; you can redistribute it and/or modify *
12
* it under the terms of the Mozilla Public License Version 2.0 as published *
13
* by the Mozilla Foundation; either version 2 of the License, or *
14
* (at your option) any later version. *
15
* *
16
* This program is distributed in the hope that it will be useful, *
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19
* Mozilla Public License Version 2.0 *
20
* (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21
****************************************************************************/
22
23
#ifndef VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_MESH_UNIFORMS_H
24
#define VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_MESH_UNIFORMS_H
25
26
#include <vclib/bgfx/uniform.h>
27
#include <vclib/mesh/requirements.h>
28
29
namespace
vcl {
30
31
class
DrawableMeshUniforms
32
{
33
float
mMeshColor[4] = {0.5, 0.5, 0.5, 1.0};
34
35
float
mModelMatrix[16] = {
// identity matrix
36
1.0,
37
0.0,
38
0.0,
39
0.0,
40
0.0,
41
1.0,
42
0.0,
43
0.0,
44
0.0,
45
0.0,
46
1.0,
47
0.0,
48
0.0,
49
0.0,
50
0.0,
51
1.0};
52
53
Uniform
mMeshColorUniform =
Uniform
(
"u_meshColor"
, bgfx::UniformType::Vec4);
54
55
// ShaderUniform modelUH =
56
// ShaderUniform("u_model", bgfx::UniformType::Mat4);
57
58
public
:
59
DrawableMeshUniforms
() =
default
;
60
61
const
float
* currentMeshColor()
const
{
return
mMeshColor; }
62
63
const
float
* currentModelMatrix()
const
{
return
mModelMatrix; }
64
65
template
<MeshConcept MeshType>
66
void
update(
const
MeshType&
m
)
67
{
68
if
constexpr
(
HasColor<MeshType>
) {
69
mMeshColor[0] =
m
.color().redF();
70
mMeshColor[1] =
m
.color().greenF();
71
mMeshColor[2] =
m
.color().blueF();
72
mMeshColor[3] =
m
.color().alphaF();
73
}
74
}
75
76
void
bind()
const
77
{
78
mMeshColorUniform.bind(mMeshColor);
79
// modelUH.bind(mModelMatrix);
80
}
81
};
82
83
}
// namespace vcl
84
85
#endif
// VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_MESH_UNIFORMS_H
vcl::DrawableMeshUniforms
Definition
drawable_mesh_uniforms.h:32
vcl::Segment
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition
segment.h:43
vcl::Uniform
The Uniform class wraps a bgfx::UniformHandle and provides a simple interface to set the uniform data...
Definition
uniform.h:43
vcl::HasColor
Concept that is evaluated true if a Mesh has the Color component.
Definition
per_mesh.h:69
vclib
render
include
vclib
bgfx
drawable
uniforms
drawable_mesh_uniforms.h
Generated by
1.9.8