Open3D (C++ API)  0.18.0
RenderToBuffer.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 <cstdint>
11 #include <functional>
12 #include <memory>
13 
14 namespace open3d {
15 namespace visualization {
16 namespace rendering {
17 
18 class Scene;
19 class View;
20 
22 public:
23  struct Buffer {
27  const std::uint8_t* bytes = nullptr;
29  };
30 
31  using BufferReadyCallback = std::function<void(const Buffer&)>;
32 
33  virtual ~RenderToBuffer() = default;
34 
35  // Sets a callback that will be called after rendering is finished
36  // and after the BufferReadyCallback from Configure() is finished.
37  // This callback can be used to deallocate the object. In particular,
38  // SetCleanupCallback([](RenderToBuffer *self) { delete self; });
39  // is valid.
40  void SetCleanupCallback(std::function<void(RenderToBuffer*)> cb) {
41  cleanup_callback_ = cb;
42  }
43 
44  // BufferReadyCallback does not need to free Buffer::bytes.
45  // It should also not cache the pointer.
46  virtual void Configure(const View* view,
47  Scene* scene,
48  int width,
49  int height,
50  int n_channels,
51  bool depth_image,
52  BufferReadyCallback cb) = 0;
54  virtual View& GetView() = 0;
55 
56  virtual void Render() = 0;
57 
58 protected:
60 };
61 
62 } // namespace rendering
63 } // namespace visualization
64 } // namespace open3d
void SetCleanupCallback(std::function< void(RenderToBuffer *)> cb)
Definition: RenderToBuffer.h:40
virtual void Configure(const View *view, Scene *scene, int width, int height, int n_channels, bool depth_image, BufferReadyCallback cb)=0
std::function< void(RenderToBuffer *)> cleanup_callback_
Definition: RenderToBuffer.h:59
virtual void SetDimensions(std::uint32_t width, std::uint32_t height)=0
std::function< void(const Buffer &)> BufferReadyCallback
Definition: RenderToBuffer.h:31
int width
Definition: FilePCD.cpp:52
int height
Definition: FilePCD.cpp:53
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 uint32_t
Definition: K4aPlugin.cpp:548
const char const char value recording_handle imu_sample void
Definition: K4aPlugin.cpp:250
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 const const k4a_calibration_t calibration const k4a_calibration_t const k4a_float2_t const const const k4a_float3_t int valid const k4a_calibration_t const k4a_float2_t const const const k4a_float2_t int valid transformation_handle const depth_image
Definition: K4aPlugin.cpp:822
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:719
Definition: PinholeCameraIntrinsic.cpp:16
std::size_t height
Definition: RenderToBuffer.h:25
std::size_t width
Definition: RenderToBuffer.h:24
std::size_t size
Definition: RenderToBuffer.h:28
const std::uint8_t * bytes
Definition: RenderToBuffer.h:27
std::size_t n_channels
Definition: RenderToBuffer.h:26