Open3D (C++ API)  0.17.0
TextureSimpleShader.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 <Eigen/Core>
11 #include <vector>
12 
14 
15 namespace open3d {
16 namespace visualization {
17 
18 namespace glsl {
19 
21 public:
22  ~TextureSimpleShader() override { Release(); }
23 
24 protected:
25  TextureSimpleShader(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,
47  std::vector<Eigen::Vector3f> &points,
48  std::vector<Eigen::Vector2f> &uvs) = 0;
49 
50 protected:
52  GLuint vertex_uv_;
53  GLuint texture_;
54  GLuint MVP_;
55 
57  std::vector<int> array_offsets_;
58  std::vector<GLsizei> draw_array_sizes_;
59 
60  std::vector<GLuint> vertex_position_buffers_;
61  std::vector<GLuint> vertex_uv_buffers_;
62  std::vector<GLuint> texture_buffers_;
63 };
64 
66 public:
68  : TextureSimpleShader("TextureSimpleShaderForTriangleMesh") {}
69 
70 protected:
71  bool PrepareRendering(const geometry::Geometry &geometry,
72  const RenderOption &option,
73  const ViewControl &view) final;
74  bool PrepareBinding(const geometry::Geometry &geometry,
75  const RenderOption &option,
76  const ViewControl &view,
77  std::vector<Eigen::Vector3f> &points,
78  std::vector<Eigen::Vector2f> &uvs) final;
79 };
80 
81 } // namespace glsl
82 
83 } // namespace visualization
84 } // 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
Definition: ShaderWrapper.h:21
TextureSimpleShaderForTriangleMesh()
Definition: TextureSimpleShader.h:67
Definition: TextureSimpleShader.h:20
void Release() final
Definition: TextureSimpleShader.cpp:31
std::vector< GLuint > texture_buffers_
Definition: TextureSimpleShader.h:62
std::vector< GLuint > vertex_uv_buffers_
Definition: TextureSimpleShader.h:61
~TextureSimpleShader() override
Definition: TextureSimpleShader.h:22
int num_materials_
Definition: TextureSimpleShader.h:56
GLuint vertex_position_
Definition: TextureSimpleShader.h:51
GLuint MVP_
Definition: TextureSimpleShader.h:54
TextureSimpleShader(const std::string &name)
Definition: TextureSimpleShader.h:25
std::vector< GLsizei > draw_array_sizes_
Definition: TextureSimpleShader.h:58
bool BindGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: TextureSimpleShader.cpp:36
GLuint texture_
Definition: TextureSimpleShader.h:53
std::vector< GLuint > vertex_position_buffers_
Definition: TextureSimpleShader.h:60
bool RenderGeometry(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view) final
Definition: TextureSimpleShader.cpp:73
bool Compile() final
Definition: TextureSimpleShader.cpp:18
GLuint vertex_uv_
Definition: TextureSimpleShader.h:52
std::vector< int > array_offsets_
Definition: TextureSimpleShader.h:57
virtual bool PrepareRendering(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view)=0
void UnbindGeometry() final
Definition: TextureSimpleShader.cpp:106
virtual bool PrepareBinding(const geometry::Geometry &geometry, const RenderOption &option, const ViewControl &view, std::vector< Eigen::Vector3f > &points, std::vector< Eigen::Vector2f > &uvs)=0
std::string name
Definition: FilePCD.cpp:39
int points
Definition: FilePCD.cpp:54
Definition: NonRigidOptimizer.cpp:22
Definition: PinholeCameraIntrinsic.cpp:16
Definition: Device.h:107