Open3D (C++ API)  0.11.0
Renderer.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // The MIT License (MIT)
5 //
6 // Copyright (c) 2019 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 
32 
33 namespace open3d {
34 
35 namespace geometry {
36 class Image;
37 }
38 
39 namespace visualization {
40 namespace rendering {
41 
42 class RenderToBuffer;
43 class Scene;
44 class View;
45 
47 public:
48  using ErrorCallback = std::function<void(
49  const ResourceLoadRequest&, const uint8_t, const std::string&)>;
50 
51  ResourceLoadRequest(const void* data, size_t data_size);
52  explicit ResourceLoadRequest(const char* path);
53 
54  ResourceLoadRequest(const void* data,
55  size_t data_size,
56  ErrorCallback error_callback);
57  ResourceLoadRequest(const char* path, ErrorCallback error_callback);
58 
59  const void* data_;
60  const size_t data_size_;
61  const std::string path_;
63 };
64 
65 class Renderer {
66 public:
67  virtual ~Renderer() = default;
68 
69  virtual SceneHandle CreateScene() = 0;
70  virtual Scene* GetScene(const SceneHandle& id) const = 0;
71  virtual void DestroyScene(const SceneHandle& id) = 0;
72 
73  virtual void SetClearColor(const Eigen::Vector4f& color) = 0;
74  virtual void SetPreserveBuffer(bool preserve) = 0;
75  virtual void UpdateSwapChain() = 0;
76 
77  virtual void EnableCaching(bool enable) = 0;
78  virtual void BeginFrame() = 0;
79  virtual void Draw() = 0;
80  virtual void EndFrame() = 0;
81 
82  virtual MaterialHandle AddMaterial(const ResourceLoadRequest& request) = 0;
83  virtual MaterialInstanceHandle AddMaterialInstance(
84  const MaterialHandle& material) = 0;
85  virtual MaterialModifier& ModifyMaterial(const MaterialHandle& id) = 0;
86  virtual MaterialModifier& ModifyMaterial(
87  const MaterialInstanceHandle& id) = 0;
88  virtual void RemoveMaterialInstance(const MaterialInstanceHandle& id) = 0;
89 
90  virtual TextureHandle AddTexture(const ResourceLoadRequest& request,
91  bool srgb = false) = 0;
92  virtual TextureHandle AddTexture(
93  const std::shared_ptr<geometry::Image>& image,
94  bool srgb = false) = 0;
95  virtual void RemoveTexture(const TextureHandle& id) = 0;
96 
97  virtual IndirectLightHandle AddIndirectLight(
98  const ResourceLoadRequest& request) = 0;
99  virtual void RemoveIndirectLight(const IndirectLightHandle& id) = 0;
100 
101  virtual SkyboxHandle AddSkybox(const ResourceLoadRequest& request) = 0;
102  virtual void RemoveSkybox(const SkyboxHandle& id) = 0;
103 
104  virtual std::shared_ptr<RenderToBuffer> CreateBufferRenderer() = 0;
105 
106  void RenderToImage(
107  View* view,
108  Scene* scene,
109  std::function<void(std::shared_ptr<geometry::Image>)> cb);
110 };
111 
112 } // namespace rendering
113 } // namespace visualization
114 } // namespace open3d
ErrorCallback error_callback_
Definition: Renderer.h:62
Definition: MaterialModifier.h:126
const size_t data_size_
Definition: Renderer.h:60
const void * data_
Definition: Renderer.h:59
std::function< void(const ResourceLoadRequest &, const uint8_t, const std::string &)> ErrorCallback
Definition: Renderer.h:49
math::float4 color
Definition: LineSetBuffers.cpp:63
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:256
const std::string path_
Definition: Renderer.h:61
Definition: PinholeCameraIntrinsic.cpp:35
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:271