Open3D (C++ API)
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 
41 class RenderToBuffer;
42 class Scene;
43 class View;
44 
46 public:
47  using ErrorCallback = std::function<void(
48  const ResourceLoadRequest&, const uint8_t, const std::string&)>;
49 
50  ResourceLoadRequest(const void* data, size_t data_size);
51  explicit ResourceLoadRequest(const char* path);
52 
53  ResourceLoadRequest(const void* data,
54  size_t data_size,
55  ErrorCallback error_callback);
56  ResourceLoadRequest(const char* path, ErrorCallback error_callback);
57 
58  const void* data_;
59  const size_t data_size_;
60  const std::string path_;
62 };
63 
64 class Renderer {
65 public:
66  virtual ~Renderer() = default;
67 
68  virtual SceneHandle CreateScene() = 0;
69  virtual Scene* GetScene(const SceneHandle& id) const = 0;
70  virtual void DestroyScene(const SceneHandle& id) = 0;
71 
72  virtual void UpdateSwapChain() = 0;
73 
74  virtual void BeginFrame() = 0;
75  virtual void Draw() = 0;
76  virtual void EndFrame() = 0;
77 
78  virtual MaterialHandle AddMaterial(const ResourceLoadRequest& request) = 0;
79  virtual MaterialInstanceHandle AddMaterialInstance(
80  const MaterialHandle& material) = 0;
81  virtual MaterialInstanceHandle AddMaterialInstance(
82  const geometry::TriangleMesh::Material& material) = 0;
83  virtual MaterialModifier& ModifyMaterial(const MaterialHandle& id) = 0;
84  virtual MaterialModifier& ModifyMaterial(
85  const MaterialInstanceHandle& id) = 0;
86  virtual void RemoveMaterialInstance(const MaterialInstanceHandle& id) = 0;
87 
88  virtual TextureHandle AddTexture(const ResourceLoadRequest& request) = 0;
89  virtual TextureHandle AddTexture(
90  const std::shared_ptr<geometry::Image>& image) = 0;
91  virtual void RemoveTexture(const TextureHandle& id) = 0;
92 
93  virtual IndirectLightHandle AddIndirectLight(
94  const ResourceLoadRequest& request) = 0;
95  virtual void RemoveIndirectLight(const IndirectLightHandle& id) = 0;
96 
97  virtual SkyboxHandle AddSkybox(const ResourceLoadRequest& request) = 0;
98  virtual void RemoveSkybox(const SkyboxHandle& id) = 0;
99 
100  virtual std::shared_ptr<RenderToBuffer> CreateBufferRenderer() = 0;
101 
102  void RenderToImage(
105  View* view,
106  Scene* scene,
107  std::function<void(std::shared_ptr<geometry::Image>)> cb);
108 };
109 
110 } // namespace visualization
111 } // namespace open3d
Definition: MaterialModifier.h:116
Definition: TriangleMesh.h:746
const void * data_
Definition: Renderer.h:58
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:255
ErrorCallback error_callback_
Definition: Renderer.h:61
Definition: Renderer.h:64
Definition: View.h:37
std::function< void(const ResourceLoadRequest &, const uint8_t, const std::string &)> ErrorCallback
Definition: Renderer.h:48
const size_t data_size_
Definition: Renderer.h:59
Definition: Open3DViewer.h:29
Definition: RendererHandle.h:110
int height
Definition: FilePCD.cpp:70
const char const char value recording_handle imu_sample recording_handle uint8_t size_t data_size k4a_record_configuration_t config target_format k4a_capture_t capture_handle k4a_imu_sample_t imu_sample playback_handle k4a_logging_message_cb_t void min_level device_handle k4a_imu_sample_t timeout_in_ms capture_handle capture_handle capture_handle image_handle temperature_c k4a_image_t image_handle uint8_t image_handle image_handle image_handle image_handle image_handle timestamp_usec white_balance image_handle k4a_device_configuration_t config device_handle char size_t serial_number_size bool int32_t int32_t int32_t int32_t k4a_color_control_mode_t default_mode value const const k4a_calibration_t calibration char size_t
Definition: K4aPlugin.cpp:720
Definition: Scene.h:47
int width
Definition: FilePCD.cpp:69
const std::string path_
Definition: Renderer.h:60
const char const char value recording_handle imu_sample recording_handle uint8_t data
Definition: K4aPlugin.cpp:270