Open3D (C++ API)
ImageMaskShader.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 
38 public:
39  ~ImageMaskShader() override { Release(); }
40 
41 protected:
42  ImageMaskShader(const std::string &name) : ShaderWrapper(name) {
43  Compile();
44  }
45 
46 protected:
47  bool Compile() final;
48  void Release() final;
49  bool BindGeometry(const geometry::Geometry &geometry,
50  const RenderOption &option,
51  const ViewControl &view) final;
52  bool RenderGeometry(const geometry::Geometry &geometry,
53  const RenderOption &option,
54  const ViewControl &view) final;
55  void UnbindGeometry() final;
56 
57 protected:
58  virtual bool PrepareRendering(const geometry::Geometry &geometry,
59  const RenderOption &option,
60  const ViewControl &view) = 0;
61  virtual bool PrepareBinding(const geometry::Geometry &geometry,
62  const RenderOption &option,
63  const ViewControl &view,
64  geometry::Image &image) = 0;
65 
66 protected:
69  GLuint vertex_UV_;
73  GLuint mask_color_;
74  GLuint mask_alpha_;
75 
78 };
79 
81 public:
82  ImageMaskShaderForImage() : ImageMaskShader("ImageMaskShaderForImage") {}
83 
84 protected:
85  virtual bool PrepareRendering(const geometry::Geometry &geometry,
86  const RenderOption &option,
87  const ViewControl &view) final;
88  virtual bool PrepareBinding(const geometry::Geometry &geometry,
89  const RenderOption &option,
90  const ViewControl &view,
91  geometry::Image &render_image) final;
92 };
93 
94 } // namespace glsl
95 
96 } // namespace visualization
97 } // namespace open3d
open3d::visualization::glsl::ImageMaskShader::mask_alpha_data_
GLfloat mask_alpha_data_
Definition: ImageMaskShader.h:77
open3d::visualization::glsl::ImageMaskShader::Compile
bool Compile() final
Definition: ImageMaskShader.cpp:40
open3d::visualization::glsl::ImageMaskShader::PrepareBinding
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, geometry::Image &image)=0
open3d::visualization::glsl::ImageMaskShader::vertex_position_buffer_
GLuint vertex_position_buffer_
Definition: ImageMaskShader.h:68
open3d::visualization::glsl::ImageMaskShader::image_texture_
GLuint image_texture_
Definition: ImageMaskShader.h:71
open3d::visualization::glsl::ImageMaskShader::Release
void Release() final
Definition: ImageMaskShader.cpp:54
open3d::visualization::glsl::ImageMaskShader::vertex_UV_buffer_
GLuint vertex_UV_buffer_
Definition: ImageMaskShader.h:70
open3d::visualization::glsl::ImageMaskShaderForImage
Definition: ImageMaskShader.h:80
open3d::visualization::glsl::ImageMaskShader::PrepareRendering
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
open3d::visualization::RenderOption
Definition: RenderOption.h:36
open3d::visualization::glsl::ImageMaskShader::mask_color_
GLuint mask_color_
Definition: ImageMaskShader.h:73
open3d::visualization::glsl::ImageMaskShader::vertex_UV_
GLuint vertex_UV_
Definition: ImageMaskShader.h:69
open3d::visualization::glsl::ImageMaskShader::RenderGeometry
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: ImageMaskShader.cpp:116
open3d::visualization::glsl::ImageMaskShader::image_texture_buffer_
GLuint image_texture_buffer_
Definition: ImageMaskShader.h:72
open3d::visualization::glsl::ImageMaskShader::UnbindGeometry
void UnbindGeometry() final
Definition: ImageMaskShader.cpp:143
Image.h
open3d::geometry::Image
The Image class stores image with customizable width, height, num of channels and bytes per channel.
Definition: Image.h:53
open3d::geometry::Geometry
The base geometry class.
Definition: Geometry.h:35
open3d::visualization::glsl::ImageMaskShader
Definition: ImageMaskShader.h:37
open3d::visualization::glsl::ImageMaskShader::ImageMaskShader
ImageMaskShader(const std::string &name)
Definition: ImageMaskShader.h:42
name
std::string name
Definition: FilePCD.cpp:55
open3d::visualization::glsl::ImageMaskShader::mask_color_data_
GLHelper::GLVector3f mask_color_data_
Definition: ImageMaskShader.h:76
ShaderWrapper.h
open3d::visualization::GLHelper::GLVector3f
Eigen::Matrix< GLfloat, 3, 1, Eigen::ColMajor > GLVector3f
Definition: GLHelper.h:44
open3d::visualization::glsl::ShaderWrapper
Definition: ShaderWrapper.h:40
open3d::visualization::ViewControl
Definition: ViewControl.h:38
open3d::visualization::glsl::ImageMaskShader::mask_alpha_
GLuint mask_alpha_
Definition: ImageMaskShader.h:74
open3d
Definition: PinholeCameraIntrinsic.cpp:34
open3d::visualization::glsl::ImageMaskShaderForImage::ImageMaskShaderForImage
ImageMaskShaderForImage()
Definition: ImageMaskShader.h:82
open3d::visualization::glsl::ImageMaskShader::vertex_position_
GLuint vertex_position_
Definition: ImageMaskShader.h:67
open3d::visualization::glsl::ImageMaskShader::BindGeometry
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: ImageMaskShader.cpp:59
open3d::visualization::glsl::ImageMaskShader::~ImageMaskShader
~ImageMaskShader() override
Definition: ImageMaskShader.h:39