Visual Computing Library  devel
Loading...
Searching...
No Matches
cpu_generated_lines.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_PRIMITIVES_LINES_CPU_GENERATED_LINES_H
24#define VCL_BGFX_PRIMITIVES_LINES_CPU_GENERATED_LINES_H
25
26#include <vclib/bgfx/buffers.h>
27#include <vclib/bgfx/context.h>
28
29namespace vcl::detail {
30
31// Note: copy constructor and assignment are not allowed (because of bgfx
32// handles). Move constructor and assignment are allowed.
33class CPUGeneratedLines
34{
35 bgfx::ProgramHandle mLinesPH =
37 .programManager()
38 .getProgram<VertFragProgram::CUSTOM_CPU_LINES>();
39
40 VertexBuffer mVertexCoords;
41 VertexBuffer mVertexNormals;
42 VertexBuffer mVertexColors;
43 IndexBuffer mLineColors;
44
45 IndexBuffer mIndices;
46
47public:
48 CPUGeneratedLines() = default;
49
50 CPUGeneratedLines(
51 const std::vector<float>& vertCoords,
52 const std::vector<float>& vertNormals = std::vector<float>(),
53 const std::vector<uint>& vertColors = std::vector<uint>(),
54 const std::vector<uint>& lineColors = std::vector<uint>());
55
56 CPUGeneratedLines(
57 const std::vector<float>& vertCoords,
58 const std::vector<uint>& lineIndices,
59 const std::vector<float>& vertNormals = std::vector<float>(),
60 const std::vector<uint>& vertColors = std::vector<uint>(),
61 const std::vector<uint>& lineColors = std::vector<uint>());
62
63 void swap(CPUGeneratedLines& other);
64
65 friend void swap(CPUGeneratedLines& a, CPUGeneratedLines& b) { a.swap(b); }
66
67 void setPoints(
68 const std::vector<float>& vertCoords,
69 const std::vector<float>& vertNormals = std::vector<float>(),
70 const std::vector<uint>& vertColors = std::vector<uint>(),
71 const std::vector<uint>& lineColors = std::vector<uint>());
72
73 void setPoints(
74 const std::vector<float>& vertCoords,
75 const std::vector<uint>& lineIndices,
76 const std::vector<float>& vertNormals = std::vector<float>(),
77 const std::vector<uint>& vertColors = std::vector<uint>(),
78 const std::vector<uint>& lineColors = std::vector<uint>());
79
80 void draw(uint viewId) const;
81
82private:
83 void setPoints(
84 bool setLineIndices,
85 const std::vector<float>& vertCoords,
86 const std::vector<uint>& lineIndices,
87 const std::vector<float>& vertNormals,
88 const std::vector<uint>& vertColors,
89 const std::vector<uint>& lineColors);
90};
91
92} // namespace vcl::detail
93
94#endif // VCL_BGFX_PRIMITIVES_LINES_CPU_GENERATED_LINES_H
static Context & instance(void *windowHandle=nullptr, void *displayHandle=nullptr)
Return the context instance.
Definition context.cpp:371