rs_processing_gl.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_PROCESSING_GL_HPP
5 #define LIBREALSENSE_RS2_PROCESSING_GL_HPP
6 
7 #include <librealsense2/rs.hpp>
8 #include "rs_processing_gl.h"
9 
10 #include <memory>
11 
12 namespace rs2
13 {
14  namespace gl
15  {
16  class pointcloud;
17  class yuy_to_rgb;
18 
19  inline void shutdown_rendering()
20  {
21  rs2_error* e = nullptr;
23  error::handle(e);
24  }
25 
26 #ifdef _glfw3_h_
27  inline void init_rendering(bool use_glsl = true)
28  {
29  rs2_error* e = nullptr;
30 
31  glfw_binding binding{
32  nullptr,
40  };
41 
42  rs2_gl_init_rendering_glfw(RS2_API_VERSION, binding, use_glsl ? 1 : 0, &e);
43  error::handle(e);
44  }
45 #else
46  inline void init_rendering(bool use_glsl = true)
47  {
48  rs2_error* e = nullptr;
49  rs2_gl_init_rendering(RS2_API_VERSION, use_glsl ? 1 : 0, &e);
50  error::handle(e);
51  }
52 #endif
53 
54  inline void init_processing(bool use_glsl = true)
55  {
56  rs2_error* e = nullptr;
57  rs2_gl_init_processing(RS2_API_VERSION, use_glsl ? 1 : 0, &e);
58  error::handle(e);
59  }
60 
61  inline void shutdown_processing()
62  {
63  rs2_error* e = nullptr;
65  error::handle(e);
66  }
67 
68 #ifdef _glfw3_h_
69  inline void init_processing(GLFWwindow* share_with, bool use_glsl = true)
70  {
71  rs2_error* e = nullptr;
72 
73  glfw_binding binding{
74  nullptr,
82  };
83 
84  rs2_gl_init_processing_glfw(RS2_API_VERSION, share_with, binding, use_glsl ? 1 : 0, &e);
85  error::handle(e);
86  }
87 #endif
88 
93  class gpu_frame : public frame
94  {
95  public:
96  gpu_frame(const frame& f)
97  : frame(f)
98  {
99  rs2_error* e = nullptr;
100  if (!f || (rs2_gl_is_frame_extendable_to(f.get(), RS2_GL_EXTENSION_VIDEO_FRAME, &e) == 0 && !e))
101  {
102  reset();
103  }
104  error::handle(e);
105  }
106 
107  uint32_t get_texture_id(unsigned int id = 0) const
108  {
109  rs2_error * e = nullptr;
110  auto r = rs2_gl_frame_get_texture_id(get(), id, &e);
111  error::handle(e);
112  return r;
113  }
114  };
115 
121  {
122  public:
124 
125  private:
126  std::shared_ptr<rs2_processing_block> init()
127  {
128  rs2_error* e = nullptr;
129  auto block = std::shared_ptr<rs2_processing_block>(
132  error::handle(e);
133 
134  // Redirect options API to the processing block
135  //options::operator=(pb);
136 
137  return block;
138  }
139  };
140 
145  class colorizer : public rs2::colorizer
146  {
147  public:
149 
150  private:
151  std::shared_ptr<rs2_processing_block> init()
152  {
153  rs2_error* e = nullptr;
154  auto block = std::shared_ptr<rs2_processing_block>(
157  error::handle(e);
158 
159  return block;
160  }
161  };
162 
163  class uploader : public rs2::filter
164  {
165  public:
166  uploader() : rs2::filter(init()) { }
167 
168  private:
169  std::shared_ptr<rs2_processing_block> init()
170  {
171  rs2_error* e = nullptr;
172  auto block = std::shared_ptr<rs2_processing_block>(
175  error::handle(e);
176  return block;
177  }
178  };
179 
185  {
186  public:
188 
190  : rs2::pointcloud(init())
191  {
192  set_option(RS2_OPTION_STREAM_FILTER, float(stream));
193  set_option(RS2_OPTION_STREAM_INDEX_FILTER, float(index));
194  }
195 
196  private:
197  friend class context;
198 
199  std::shared_ptr<rs2_processing_block> init()
200  {
201  rs2_error* e = nullptr;
202 
203  auto block = std::shared_ptr<rs2_processing_block>(
206 
207  error::handle(e);
208 
209  return block;
210  }
211  };
212 
219  {
220  public:
222 
223  void set_matrix(rs2_gl_matrix_type type, float* m4x4)
224  {
225  rs2_error* e = nullptr;
226  rs2_gl_set_matrix(get(), type, m4x4, &e);
227  error::handle(e);
228  }
229 
230  static const auto OPTION_MOUSE_X = rs2_option(RS2_OPTION_COUNT + 1);
231  static const auto OPTION_MOUSE_Y = rs2_option(RS2_OPTION_COUNT + 2);
232  static const auto OPTION_MOUSE_PICK = rs2_option(RS2_OPTION_COUNT + 3);
233  static const auto OPTION_WAS_PICKED = rs2_option(RS2_OPTION_COUNT + 4);
234  static const auto OPTION_SELECTED = rs2_option(RS2_OPTION_COUNT + 5);
235  private:
236  friend class context;
237 
238  std::shared_ptr<rs2_processing_block> init()
239  {
240  rs2_error* e = nullptr;
241 
242  auto block = std::shared_ptr<rs2_processing_block>(
245 
246  error::handle(e);
247  return block;
248  }
249  };
250 
258  {
259  public:
261 
262  void set_matrix(rs2_gl_matrix_type type, float* m4x4)
263  {
264  rs2_error* e = nullptr;
265  rs2_gl_set_matrix(get(), type, m4x4, &e);
266  error::handle(e);
267  }
268 
269  static const auto OPTION_FILLED = rs2_option(RS2_OPTION_COUNT + 1);
270  static const auto OPTION_SHADED = rs2_option(RS2_OPTION_COUNT + 2);
271 
272  static const auto OPTION_MOUSE_X = rs2_option(RS2_OPTION_COUNT + 3);
273  static const auto OPTION_MOUSE_Y = rs2_option(RS2_OPTION_COUNT + 4);
274  static const auto OPTION_MOUSE_PICK = rs2_option(RS2_OPTION_COUNT + 5);
275 
276  static const auto OPTION_PICKED_X = rs2_option(RS2_OPTION_COUNT + 6);
277  static const auto OPTION_PICKED_Y = rs2_option(RS2_OPTION_COUNT + 7);
278  static const auto OPTION_PICKED_Z = rs2_option(RS2_OPTION_COUNT + 8);
279 
280  static const auto OPTION_PICKED_ID = rs2_option(RS2_OPTION_COUNT + 9);
281  static const auto OPTION_SELECTED = rs2_option(RS2_OPTION_COUNT + 10);
282  static const auto OPTION_ORIGIN_PICKED = rs2_option(RS2_OPTION_COUNT + 11);
283 
284  static const auto OPTION_NORMAL_X = rs2_option(RS2_OPTION_COUNT + 12);
285  static const auto OPTION_NORMAL_Y = rs2_option(RS2_OPTION_COUNT + 13);
286  static const auto OPTION_NORMAL_Z = rs2_option(RS2_OPTION_COUNT + 14);
287 
288  static const auto OPTION_SCALE_FACTOR = rs2_option(RS2_OPTION_COUNT + 15);
289 
290  private:
291  friend class context;
292 
293  std::shared_ptr<rs2_processing_block> init()
294  {
295  rs2_error* e = nullptr;
296 
297  auto block = std::shared_ptr<rs2_processing_block>(
300 
301  error::handle(e);
302  return block;
303  }
304  };
305 
308  class align : public rs2::align
309  {
310  public:
311  align(rs2_stream to) : rs2::align(init(to)) {}
312 
313  private:
314  friend class context;
315 
316  std::shared_ptr<rs2_processing_block> init(rs2_stream to)
317  {
318  rs2_error* e = nullptr;
319 
320  auto block = std::shared_ptr<rs2_processing_block>(
323 
324  error::handle(e);
325 
326  return block;
327  }
328  };
329  }
330 }
331 #endif // LIBREALSENSE_RS2_PROCESSING_GL_HPP
void init_processing(bool use_glsl=true)
rs2_processing_block * rs2_gl_create_colorizer(int api_version, rs2_error **error)
void rs2_gl_shutdown_processing(int api_version, rs2_error **error)
#define RS2_API_VERSION
Definition: rs.h:41
rs2_frame * get() const
Definition: rs_frame.hpp:590
std::shared_ptr< rs2_processing_block > init()
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
GLFWAPI GLFWglproc glfwGetProcAddress(const char *procname)
Returns the address of the specified function for the current context.
Definition: context.c:741
std::shared_ptr< rs2_processing_block > init()
void rs2_gl_init_rendering_glfw(int api_version, glfw_binding bindings, int use_glsl, rs2_error **error)
rs2_processing_block * rs2_gl_create_pointcloud_renderer(int api_version, rs2_error **error)
std::shared_ptr< rs2_processing_block > init()
pointcloud(rs2_stream stream, int index=0)
void rs2_gl_shutdown_rendering(int api_version, rs2_error **error)
std::shared_ptr< rs2_processing_block > init()
Definition: cah-model.h:10
int rs2_gl_is_frame_extendable_to(const rs2_frame *f, rs2_gl_extension extension_type, rs2_error **error)
gpu_frame(const frame &f)
rs2_processing_block * rs2_gl_create_yuy_decoder(int api_version, rs2_error **error)
GLuint GLuint stream
Definition: glext.h:1790
e
Definition: rmse.py:177
void shutdown_processing()
void reset()
Definition: rs_frame.hpp:611
void set_matrix(rs2_gl_matrix_type type, float *m4x4)
GLuint index
GLdouble f
std::shared_ptr< rs2_processing_block > init(rs2_stream to)
Exposes RealSense processing-block functionality for GPU for C compilers.
void rs2_gl_set_matrix(rs2_processing_block *block, rs2_gl_matrix_type type, float *m4x4, rs2_error **error)
void set_matrix(rs2_gl_matrix_type type, float *m4x4)
GLdouble GLdouble r
void shutdown_rendering()
GLFWAPI void glfwSwapInterval(int interval)
Sets the swap interval for the current context.
Definition: context.c:658
unsigned int uint32_t
Definition: stdint.h:80
align(rs2_stream to)
GLFWAPI void glfwMakeContextCurrent(GLFWwindow *window)
Makes the context of the specified window current for the calling thread.
Definition: context.c:611
void init(void)
Definition: boing.c:180
void rs2_delete_processing_block(rs2_processing_block *block)
Definition: rs.cpp:2106
void init_rendering(bool use_glsl=true)
static void handle(rs2_error *e)
Definition: rs_types.hpp:144
std::shared_ptr< rs2_processing_block > init()
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition: rs_sensor.h:42
uint32_t get_texture_id(unsigned int id=0) const
void rs2_gl_init_processing_glfw(int api_version, GLFWwindow *share_with, glfw_binding bindings, int use_glsl, rs2_error **error)
GLFWAPI GLFWwindow * glfwCreateWindow(int width, int height, const char *title, GLFWmonitor *monitor, GLFWwindow *share)
Creates a window and its associated context.
Definition: window.c:151
rs2_processing_block * rs2_gl_create_camera_renderer(int api_version, rs2_error **error)
void rs2_gl_init_rendering(int api_version, int use_glsl, rs2_error **error)
std::shared_ptr< rs2_processing_block > init()
rs2_processing_block * rs2_gl_create_uploader(int api_version, rs2_error **error)
GLenum type
GLFWAPI void glfwDestroyWindow(GLFWwindow *window)
Destroys the specified window and its context.
Definition: window.c:444
rs2_processing_block * rs2_gl_create_align(int api_version, rs2_stream to, rs2_error **error)
rs2_gl_matrix_type
unsigned int rs2_gl_frame_get_texture_id(const rs2_frame *f, unsigned int id, rs2_error **error)
rs2_processing_block * rs2_gl_create_pointcloud(int api_version, rs2_error **error)
GLFWAPI GLFWwindow * glfwGetCurrentContext(void)
Returns the window whose context is current on the calling thread.
Definition: context.c:635
struct GLFWwindow GLFWwindow
GLFWAPI void glfwWindowHint(int hint, int value)
Sets the specified window hint to the desired value.
Definition: window.c:291
void rs2_gl_init_processing(int api_version, int use_glsl, rs2_error **error)


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41