Open3D (C++ API)  0.17.0
Simple2DShader.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 Simple2DShader : public ShaderWrapper {
21 public:
22  ~Simple2DShader() override { Release(); }
23 
24 protected:
25  Simple2DShader(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<Eigen::Vector3f> &colors) = 0;
47 
48 protected:
51  GLuint vertex_color_;
53 };
54 
56 public:
58  : Simple2DShader("Simple2DShaderForSelectionPolygon") {}
59 
60 protected:
61  bool PrepareRendering(const geometry::Geometry &geometry,
62  const RenderOption &option,
63  const ViewControl &view) final;
64  bool PrepareBinding(const geometry::Geometry &geometry,
65  const RenderOption &option,
66  const ViewControl &view,
67  std::vector<Eigen::Vector3f> &points,
68  std::vector<Eigen::Vector3f> &colors) final;
69 };
70 
71 } // namespace glsl
72 
73 } // namespace visualization
74 } // 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
Definition: ShaderWrapper.h:21
Simple2DShaderForSelectionPolygon()
Definition: Simple2DShader.h:57
Definition: Simple2DShader.h:20
bool Compile() final
Definition: Simple2DShader.cpp:19
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< Eigen::Vector3f > &colors)=0
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: Simple2DShader.cpp:67
GLuint vertex_color_
Definition: Simple2DShader.h:51
GLuint vertex_color_buffer_
Definition: Simple2DShader.h:52
void Release() final
Definition: Simple2DShader.cpp:29
GLuint vertex_position_buffer_
Definition: Simple2DShader.h:50
GLuint vertex_position_
Definition: Simple2DShader.h:49
~Simple2DShader() override
Definition: Simple2DShader.h:22
Simple2DShader(const std::string &name)
Definition: Simple2DShader.h:25
void UnbindGeometry() final
Definition: Simple2DShader.cpp:87
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: Simple2DShader.cpp:34
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
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