Visual Computing Library  devel
Loading...
Searching...
No Matches
drawable_trackball_uniforms.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2026 *
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_TRACKBALL_UNIFORMS_H
24#define VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_TRACKBALL_UNIFORMS_H
25
26#include <vclib/bgfx/uniform.h>
27#include <vclib/space/core/color.h>
28
29namespace vcl {
30
39{
40 static constexpr float DRAGGING_ALPHA = 0.9f;
41 static constexpr float NOT_DRAGGING_ALPHA = 0.5f;
42
43 // the only component is alpha
44 inline static std::array<float, 4> sTrackBallSettings =
45 {NOT_DRAGGING_ALPHA, 0, 0, 0};
46
47 inline static Uniform sTrackballSettingsUniform;
48
49public:
51
52 static void setDragging(bool dragging)
53 {
54 sTrackBallSettings[0] = dragging ? DRAGGING_ALPHA : NOT_DRAGGING_ALPHA;
55 }
56
57 static void bind()
58 {
59 // lazy initialization
60 // to avoid creating uniforms before bgfx is initialized
61 if (!sTrackballSettingsUniform.isValid())
62 sTrackballSettingsUniform =
63 Uniform("u_trackballSettingsPack", bgfx::UniformType::Vec4);
64 sTrackballSettingsUniform.bind(sTrackBallSettings.data());
65 }
66};
67
68} // namespace vcl
69
70#endif // VCL_BGFX_DRAWABLE_UNIFORMS_DRAWABLE_TRACKBALL_UNIFORMS_H
The DrawableTrackballUniforms class is responsible for managing the shader uniforms related to a draw...
Definition drawable_trackball_uniforms.h:39
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:41
The Uniform class wraps a bgfx::UniformHandle and provides a simple interface to set the uniform data...
Definition uniform.h:43
void bind(const void *data) const
Sets the uniform data for the current shader program.
Definition uniform.h:165
bool isValid() const
Checks if the Uniform is valid (i.e., if it has a valid bgfx::UniformHandle).
Definition uniform.h:129