Open3D (C++ API)  0.18.0
RGBDImageShader.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 "open3d/geometry/Image.h"
12 
13 namespace open3d {
14 namespace visualization {
15 
16 namespace glsl {
17 
18 enum ImageTextureMode { Depth = 0, RGB = 1, Grayscale = 2 };
19 
21 public:
22  ~RGBDImageShader() override { Release(); }
23 
24 protected:
25  RGBDImageShader(const std::string &name) : ShaderWrapper(name) {
26  Compile();
27  }
28 
29 protected:
30  bool Compile() final;
31  void Release() final;
32  bool BindGeometry(const geometry::Geometry &geometry,
33  const RenderOption &option,
34  const ViewControl &view) final;
35  bool RenderGeometry(const geometry::Geometry &geometry,
36  const RenderOption &option,
37  const ViewControl &view) final;
38  void UnbindGeometry() final;
39 
40 protected:
41  virtual bool PrepareRendering(const geometry::Geometry &geometry,
42  const RenderOption &option,
43  const ViewControl &view) = 0;
44  virtual bool PrepareBinding(const geometry::Geometry &geometry,
45  const RenderOption &option,
46  const ViewControl &view) = 0;
47 
48 protected:
51  GLuint vertex_UV_;
57  GLuint vertex_scale_;
58  GLuint texture_mode_;
59  GLuint depth_max_;
61  float color_rel_ratio_ = 0.5f;
62 
63  /* Switches corresponding to the glsl shader */
67 };
68 
70 public:
71  RGBDImageShaderForImage() : RGBDImageShader("RGBDImageShaderForImage") {}
72 
73 protected:
74  virtual bool PrepareRendering(const geometry::Geometry &geometry,
75  const RenderOption &option,
76  const ViewControl &view) final;
77  virtual bool PrepareBinding(const geometry::Geometry &geometry,
78  const RenderOption &option,
79  const ViewControl &view) final;
80 };
81 
82 } // namespace glsl
83 
84 } // namespace visualization
85 } // 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
RGBDImageShaderForImage()
Definition: RGBDImageShader.h:71
Definition: RGBDImageShader.h:20
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: RGBDImageShader.cpp:134
void Release() final
Definition: RGBDImageShader.cpp:37
GLuint vertex_scale_
Definition: RGBDImageShader.h:57
GLuint vertex_position_buffer_
Definition: RGBDImageShader.h:50
void UnbindGeometry() final
Definition: RGBDImageShader.cpp:177
float depth_max_data_
Definition: RGBDImageShader.h:60
GLuint vertex_UV_
Definition: RGBDImageShader.h:51
GLuint texture_mode_
Definition: RGBDImageShader.h:58
GLuint color_texture_buffer_
Definition: RGBDImageShader.h:54
GLuint image_texture_
Definition: RGBDImageShader.h:53
gl_util::GLVector3f vertex_scale_data_
Definition: RGBDImageShader.h:66
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
RGBDImageShader(const std::string &name)
Definition: RGBDImageShader.h:25
GLuint vertex_position_
Definition: RGBDImageShader.h:49
GLuint vertex_UV_buffer_
Definition: RGBDImageShader.h:52
GLuint depth_max_
Definition: RGBDImageShader.h:59
float color_rel_ratio_
Definition: RGBDImageShader.h:61
ImageTextureMode color_texture_mode_
Definition: RGBDImageShader.h:65
GLuint depth_texture_buffer_
Definition: RGBDImageShader.h:56
GLuint depth_texture_
Definition: RGBDImageShader.h:55
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: RGBDImageShader.cpp:42
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
~RGBDImageShader() override
Definition: RGBDImageShader.h:22
ImageTextureMode depth_texture_mode_
Definition: RGBDImageShader.h:64
bool Compile() final
Definition: RGBDImageShader.cpp:21
Definition: ShaderWrapper.h:21
std::string name
Definition: FilePCD.cpp:39
Eigen::Matrix< GLfloat, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:32
ImageTextureMode
Definition: RGBDImageShader.h:18
@ RGB
Definition: RGBDImageShader.h:18
@ Depth
Definition: RGBDImageShader.h:18
@ Grayscale
Definition: RGBDImageShader.h:18
Definition: PinholeCameraIntrinsic.cpp:16