Open3D (C++ API)  0.16.1
SimpleShader.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// The MIT License (MIT)
5//
6// Copyright (c) 2018-2021 www.open3d.org
7//
8// Permission is hereby granted, free of charge, to any person obtaining a copy
9// of this software and associated documentation files (the "Software"), to deal
10// in the Software without restriction, including without limitation the rights
11// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12// copies of the Software, and to permit persons to whom the Software is
13// furnished to do so, subject to the following conditions:
14//
15// The above copyright notice and this permission notice shall be included in
16// all copies or substantial portions of the Software.
17//
18// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24// IN THE SOFTWARE.
25// ----------------------------------------------------------------------------
26
27#pragma once
28
29#include <Eigen/Core>
30#include <vector>
31
33
34namespace open3d {
35namespace visualization {
36
37namespace glsl {
38
40public:
41 ~SimpleShader() override { Release(); }
42
43protected:
44 SimpleShader(const std::string &name) : ShaderWrapper(name) { Compile(); }
45
46protected:
47 bool Compile() final;
48 void Release() final;
49 bool BindGeometry(const geometry::Geometry &geometry,
50 const RenderOption &option,
51 const ViewControl &view) final;
52 bool RenderGeometry(const geometry::Geometry &geometry,
53 const RenderOption &option,
54 const ViewControl &view) final;
55 void UnbindGeometry() final;
56
57protected:
58 virtual bool PrepareRendering(const geometry::Geometry &geometry,
59 const RenderOption &option,
60 const ViewControl &view) = 0;
61 virtual bool PrepareBinding(const geometry::Geometry &geometry,
62 const RenderOption &option,
63 const ViewControl &view,
64 std::vector<Eigen::Vector3f> &points,
65 std::vector<Eigen::Vector3f> &colors) = 0;
66
67protected:
72 GLuint MVP_;
73};
74
76public:
77 SimpleShaderForPointCloud() : SimpleShader("SimpleShaderForPointCloud") {}
78
79protected:
80 bool PrepareRendering(const geometry::Geometry &geometry,
81 const RenderOption &option,
82 const ViewControl &view) final;
83 bool PrepareBinding(const geometry::Geometry &geometry,
84 const RenderOption &option,
85 const ViewControl &view,
86 std::vector<Eigen::Vector3f> &points,
87 std::vector<Eigen::Vector3f> &colors) final;
88};
89
91public:
92 SimpleShaderForLineSet() : SimpleShader("SimpleShaderForLineSet") {}
93
94protected:
95 bool PrepareRendering(const geometry::Geometry &geometry,
96 const RenderOption &option,
97 const ViewControl &view) final;
98 bool PrepareBinding(const geometry::Geometry &geometry,
99 const RenderOption &option,
100 const ViewControl &view,
101 std::vector<Eigen::Vector3f> &points,
102 std::vector<Eigen::Vector3f> &colors) final;
103};
104
106public:
107 SimpleShaderForTetraMesh() : SimpleShader("SimpleShaderForTetraMesh") {}
108
109protected:
110 bool PrepareRendering(const geometry::Geometry &geometry,
111 const RenderOption &option,
112 const ViewControl &view) final;
113 bool PrepareBinding(const geometry::Geometry &geometry,
114 const RenderOption &option,
115 const ViewControl &view,
116 std::vector<Eigen::Vector3f> &points,
117 std::vector<Eigen::Vector3f> &colors) final;
118};
119
121public:
123 : SimpleShader("SimpleShaderForOrientedBoundingBox") {}
124
125protected:
126 bool PrepareRendering(const geometry::Geometry &geometry,
127 const RenderOption &option,
128 const ViewControl &view) final;
129 bool PrepareBinding(const geometry::Geometry &geometry,
130 const RenderOption &option,
131 const ViewControl &view,
132 std::vector<Eigen::Vector3f> &points,
133 std::vector<Eigen::Vector3f> &colors) final;
134};
135
137public:
139 : SimpleShader("SimpleShaderForAxisAlignedBoundingBox") {}
140
141protected:
142 bool PrepareRendering(const geometry::Geometry &geometry,
143 const RenderOption &option,
144 const ViewControl &view) final;
145 bool PrepareBinding(const geometry::Geometry &geometry,
146 const RenderOption &option,
147 const ViewControl &view,
148 std::vector<Eigen::Vector3f> &points,
149 std::vector<Eigen::Vector3f> &colors) final;
150};
151
153public:
155 : SimpleShader("SimpleShaderForTriangleMesh") {}
156
157protected:
158 bool PrepareRendering(const geometry::Geometry &geometry,
159 const RenderOption &option,
160 const ViewControl &view) final;
161 bool PrepareBinding(const geometry::Geometry &geometry,
162 const RenderOption &option,
163 const ViewControl &view,
164 std::vector<Eigen::Vector3f> &points,
165 std::vector<Eigen::Vector3f> &colors) final;
166};
167
169public:
171 : SimpleShader("SimpleShaderForVoxelGridLine") {}
172
173protected:
174 bool PrepareRendering(const geometry::Geometry &geometry,
175 const RenderOption &option,
176 const ViewControl &view) final;
177 bool PrepareBinding(const geometry::Geometry &geometry,
178 const RenderOption &option,
179 const ViewControl &view,
180 std::vector<Eigen::Vector3f> &points,
181 std::vector<Eigen::Vector3f> &colors) final;
182};
183
185public:
187 : SimpleShader("SimpleShaderForVoxelGridFace") {}
188
189protected:
190 bool PrepareRendering(const geometry::Geometry &geometry,
191 const RenderOption &option,
192 const ViewControl &view) final;
193 bool PrepareBinding(const geometry::Geometry &geometry,
194 const RenderOption &option,
195 const ViewControl &view,
196 std::vector<Eigen::Vector3f> &points,
197 std::vector<Eigen::Vector3f> &colors) final;
198};
199
201public:
202 SimpleShaderForOctreeLine() : SimpleShader("SimpleShaderForOctreeLine") {}
203
204protected:
205 bool PrepareRendering(const geometry::Geometry &geometry,
206 const RenderOption &option,
207 const ViewControl &view) final;
208 bool PrepareBinding(const geometry::Geometry &geometry,
209 const RenderOption &option,
210 const ViewControl &view,
211 std::vector<Eigen::Vector3f> &points,
212 std::vector<Eigen::Vector3f> &colors) final;
213};
214
216public:
217 SimpleShaderForOctreeFace() : SimpleShader("SimpleShaderForOctreeFace") {}
218
219protected:
220 bool PrepareRendering(const geometry::Geometry &geometry,
221 const RenderOption &option,
222 const ViewControl &view) final;
223 bool PrepareBinding(const geometry::Geometry &geometry,
224 const RenderOption &option,
225 const ViewControl &view,
226 std::vector<Eigen::Vector3f> &points,
227 std::vector<Eigen::Vector3f> &colors) final;
228};
229
230} // namespace glsl
231
232} // namespace visualization
233} // namespace open3d
The base geometry class.
Definition: Geometry.h:37
Defines rendering options for visualizer.
Definition: RenderOption.h:39
View controller for visualizer.
Definition: ViewControl.h:41
Definition: ShaderWrapper.h:40
SimpleShaderForLineSet()
Definition: SimpleShader.h:92
SimpleShaderForOctreeFace()
Definition: SimpleShader.h:217
SimpleShaderForOctreeLine()
Definition: SimpleShader.h:202
SimpleShaderForOrientedBoundingBox()
Definition: SimpleShader.h:122
SimpleShaderForPointCloud()
Definition: SimpleShader.h:77
SimpleShaderForTetraMesh()
Definition: SimpleShader.h:107
SimpleShaderForTriangleMesh()
Definition: SimpleShader.h:154
SimpleShaderForVoxelGridFace()
Definition: SimpleShader.h:186
SimpleShaderForVoxelGridLine()
Definition: SimpleShader.h:170
Definition: SimpleShader.h:39
GLuint vertex_position_
Definition: SimpleShader.h:68
GLuint MVP_
Definition: SimpleShader.h:72
GLuint vertex_color_buffer_
Definition: SimpleShader.h:71
GLuint vertex_position_buffer_
Definition: SimpleShader.h:69
~SimpleShader() override
Definition: SimpleShader.h:41
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
void UnbindGeometry() final
Definition: SimpleShader.cpp:138
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< Eigen::Vector3f > &colors)=0
void Release() final
Definition: SimpleShader.cpp:80
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: SimpleShader.cpp:117
bool Compile() final
Definition: SimpleShader.cpp:69
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: SimpleShader.cpp:85
SimpleShader(const std::string &name)
Definition: SimpleShader.h:44
GLuint vertex_color_
Definition: SimpleShader.h:70
std::string name
Definition: FilePCD.cpp:58
int points
Definition: FilePCD.cpp:73
Definition: NonRigidOptimizer.cpp:41
Definition: PinholeCameraIntrinsic.cpp:35
Definition: Device.h:126