Open3D (C++ API)  0.18.0
PickingShader.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2023 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include <Eigen/Core>
11 #include <vector>
12 
14 
15 namespace open3d {
16 namespace visualization {
17 
18 namespace glsl {
19 
20 class PickingShader : public ShaderWrapper {
21 public:
22  ~PickingShader() override { Release(); }
23 
24 protected:
25  PickingShader(const std::string &name) : ShaderWrapper(name) { Compile(); }
26 
27 protected:
28  bool Compile() final;
29  void Release() final;
30  bool BindGeometry(const geometry::Geometry &geometry,
31  const RenderOption &option,
32  const ViewControl &view) final;
33  bool RenderGeometry(const geometry::Geometry &geometry,
34  const RenderOption &option,
35  const ViewControl &view) final;
36  void UnbindGeometry() final;
37 
38 protected:
39  virtual bool PrepareRendering(const geometry::Geometry &geometry,
40  const RenderOption &option,
41  const ViewControl &view) = 0;
42  virtual bool PrepareBinding(const geometry::Geometry &geometry,
43  const RenderOption &option,
44  const ViewControl &view,
45  std::vector<Eigen::Vector3f> &points,
46  std::vector<float> &indices) = 0;
47 
48 protected:
51  GLuint vertex_index_;
53  GLuint MVP_;
54 };
55 
57 public:
59  : PickingShader("PickingShaderForPointCloud") {}
60 
61 protected:
62  bool PrepareRendering(const geometry::Geometry &geometry,
63  const RenderOption &option,
64  const ViewControl &view) final;
65  bool PrepareBinding(const geometry::Geometry &geometry,
66  const RenderOption &option,
67  const ViewControl &view,
68  std::vector<Eigen::Vector3f> &points,
69  std::vector<float> &indices) final;
70 };
71 
72 } // namespace glsl
73 
74 } // namespace visualization
75 } // namespace open3d
The base geometry class.
Definition: Geometry.h:18
Defines rendering options for visualizer.
Definition: RenderOption.h:20
View controller for visualizer.
Definition: ViewControl.h:23
PickingShaderForPointCloud()
Definition: PickingShader.h:58
Definition: PickingShader.h:20
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< float > &indices)=0
bool Compile() final
Definition: PickingShader.cpp:20
GLuint vertex_index_
Definition: PickingShader.h:51
GLuint vertex_index_buffer_
Definition: PickingShader.h:52
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: PickingShader.cpp:69
GLuint MVP_
Definition: PickingShader.h:53
GLuint vertex_position_buffer_
Definition: PickingShader.h:50
~PickingShader() override
Definition: PickingShader.h:22
PickingShader(const std::string &name)
Definition: PickingShader.h:25
void Release() final
Definition: PickingShader.cpp:31
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: PickingShader.cpp:36
void UnbindGeometry() final
Definition: PickingShader.cpp:90
GLuint vertex_position_
Definition: PickingShader.h:49
Definition: ShaderWrapper.h:21
std::string name
Definition: FilePCD.cpp:39
int points
Definition: FilePCD.cpp:54
Definition: NonRigidOptimizer.cpp:22
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Device.h:107