Open3D (C++ API)
RGBDImageShader.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 "Open3D/Geometry/Image.h"
31 
32 namespace open3d {
33 namespace visualization {
34 
35 namespace glsl {
36 
37 enum ImageTextureMode { Depth = 0, RGB = 1, Grayscale = 2 };
38 
40 public:
41  ~RGBDImageShader() override { Release(); }
42 
43 protected:
44  RGBDImageShader(const std::string &name) : ShaderWrapper(name) {
45  Compile();
46  }
47 
48 protected:
49  bool Compile() final;
50  void Release() final;
51  bool BindGeometry(const geometry::Geometry &geometry,
52  const RenderOption &option,
53  const ViewControl &view) final;
54  bool RenderGeometry(const geometry::Geometry &geometry,
55  const RenderOption &option,
56  const ViewControl &view) final;
57  void UnbindGeometry() final;
58 
59 protected:
60  virtual bool PrepareRendering(const geometry::Geometry &geometry,
61  const RenderOption &option,
62  const ViewControl &view) = 0;
63  virtual bool PrepareBinding(const geometry::Geometry &geometry,
64  const RenderOption &option,
65  const ViewControl &view) = 0;
66 
67 protected:
70  GLuint vertex_UV_;
76  GLuint vertex_scale_;
77  GLuint texture_mode_;
78  GLuint depth_max_;
80  float color_rel_ratio_ = 0.5f;
81 
82  /* Switches corresponding to the glsl shader */
86 };
87 
89 public:
90  RGBDImageShaderForImage() : RGBDImageShader("RGBDImageShaderForImage") {}
91 
92 protected:
93  virtual bool PrepareRendering(const geometry::Geometry &geometry,
94  const RenderOption &option,
95  const ViewControl &view) final;
96  virtual bool PrepareBinding(const geometry::Geometry &geometry,
97  const RenderOption &option,
98  const ViewControl &view) final;
99 };
100 
101 } // namespace glsl
102 
103 } // namespace visualization
104 } // namespace open3d
float color_rel_ratio_
Definition: RGBDImageShader.h:80
GLHelper::GLVector3f vertex_scale_data_
Definition: RGBDImageShader.h:85
Eigen::Matrix< GLfloat, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:50
The base geometry class.
Definition: Geometry.h:37
ImageTextureMode
Definition: RGBDImageShader.h:37
Definition: RGBDImageShader.h:39
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
float depth_max_data_
Definition: RGBDImageShader.h:79
ImageTextureMode color_texture_mode_
Definition: RGBDImageShader.h:84
Definition: RGBDImageShader.h:37
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: RGBDImageShader.cpp:63
GLuint vertex_UV_buffer_
Definition: RGBDImageShader.h:71
View controller for visualizer.
Definition: ViewControl.h:41
Definition: RGBDImageShader.h:37
RGBDImageShaderForImage()
Definition: RGBDImageShader.h:90
GLuint depth_texture_
Definition: RGBDImageShader.h:74
GLuint depth_texture_buffer_
Definition: RGBDImageShader.h:75
ImageTextureMode depth_texture_mode_
Definition: RGBDImageShader.h:83
Defines rendering options for visualizer.
Definition: RenderOption.h:39
GLuint vertex_UV_
Definition: RGBDImageShader.h:70
GLuint depth_max_
Definition: RGBDImageShader.h:78
void UnbindGeometry() final
Definition: RGBDImageShader.cpp:198
void Release() final
Definition: RGBDImageShader.cpp:58
GLuint vertex_scale_
Definition: RGBDImageShader.h:76
~RGBDImageShader() override
Definition: RGBDImageShader.h:41
GLuint texture_mode_
Definition: RGBDImageShader.h:77
Definition: Open3DViewer.h:29
std::string name
Definition: FilePCD.cpp:56
Definition: ShaderWrapper.h:40
GLuint color_texture_buffer_
Definition: RGBDImageShader.h:73
GLuint vertex_position_buffer_
Definition: RGBDImageShader.h:69
Definition: RGBDImageShader.h:37
bool Compile() final
Definition: RGBDImageShader.cpp:41
GLuint image_texture_
Definition: RGBDImageShader.h:72
GLuint vertex_position_
Definition: RGBDImageShader.h:68
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: RGBDImageShader.cpp:155
RGBDImageShader(const std::string &name)
Definition: RGBDImageShader.h:44