Open3D (C++ API)
Simple2DShader.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 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 <vector>
30 #include <Eigen/Core>
32 
33 namespace open3d {
34 namespace visualization {
35 
36 namespace glsl {
37 
38 class Simple2DShader : public ShaderWrapper {
39 public:
40  ~Simple2DShader() override { Release(); }
41 
42 protected:
43  Simple2DShader(const std::string &name) : ShaderWrapper(name) { Compile(); }
44 
45 protected:
46  bool Compile() final;
47  void Release() final;
48  bool BindGeometry(const geometry::Geometry &geometry,
49  const RenderOption &option,
50  const ViewControl &view) final;
51  bool RenderGeometry(const geometry::Geometry &geometry,
52  const RenderOption &option,
53  const ViewControl &view) final;
54  void UnbindGeometry() final;
55 
56 protected:
57  virtual bool PrepareRendering(const geometry::Geometry &geometry,
58  const RenderOption &option,
59  const ViewControl &view) = 0;
60  virtual bool PrepareBinding(const geometry::Geometry &geometry,
61  const RenderOption &option,
62  const ViewControl &view,
63  std::vector<Eigen::Vector3f> &points,
64  std::vector<Eigen::Vector3f> &colors) = 0;
65 
66 protected:
69  GLuint vertex_color_;
71 };
72 
74 public:
76  : Simple2DShader("Simple2DShaderForSelectionPolygon") {}
77 
78 protected:
79  bool PrepareRendering(const geometry::Geometry &geometry,
80  const RenderOption &option,
81  const ViewControl &view) final;
82  bool PrepareBinding(const geometry::Geometry &geometry,
83  const RenderOption &option,
84  const ViewControl &view,
85  std::vector<Eigen::Vector3f> &points,
86  std::vector<Eigen::Vector3f> &colors) final;
87 };
88 
89 } // namespace glsl
90 
91 } // namespace visualization
92 } // namespace open3d
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: Simple2DShader.cpp:87
GLuint vertex_position_
Definition: Simple2DShader.h:67
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: Simple2DShader.cpp:54
Definition: Geometry.h:32
Definition: ViewControl.h:38
GLuint vertex_color_
Definition: Simple2DShader.h:69
bool Compile() final
Definition: Simple2DShader.cpp:38
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< Eigen::Vector3f > &colors)=0
Definition: RenderOption.h:36
~Simple2DShader() override
Definition: Simple2DShader.h:40
GLuint vertex_color_buffer_
Definition: Simple2DShader.h:70
int points
Definition: FilePCD.cpp:69
Definition: PinholeCameraIntrinsic.cpp:33
Simple2DShader(const std::string &name)
Definition: Simple2DShader.h:43
std::string name
Definition: FilePCD.cpp:54
Definition: ShaderWrapper.h:40
void Release() final
Definition: Simple2DShader.cpp:49
void UnbindGeometry() final
Definition: Simple2DShader.cpp:107
Definition: Simple2DShader.h:38
GLuint vertex_position_buffer_
Definition: Simple2DShader.h:68
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
Simple2DShaderForSelectionPolygon()
Definition: Simple2DShader.h:75