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