Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
Loading...
Searching...
No Matches
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
8#include "rs_processing_gl.h"
9
10#include <memory>
11
12namespace 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;
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,
33 &glfwWindowHint,
34 &glfwCreateWindow,
35 &glfwDestroyWindow,
36 &glfwMakeContextCurrent,
37 &glfwGetCurrentContext,
38 &glfwSwapInterval,
39 &glfwGetProcAddress
40 };
41
42 rs2_gl_init_rendering_glfw(RS2_API_VERSION, binding, use_glsl ? 1 : 0, &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);
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);
59 }
60
61 inline void shutdown_processing()
62 {
63 rs2_error* e = nullptr;
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,
75 &glfwWindowHint,
76 &glfwCreateWindow,
77 &glfwDestroyWindow,
78 &glfwMakeContextCurrent,
79 &glfwGetCurrentContext,
80 &glfwSwapInterval,
81 &glfwGetProcAddress
82 };
83
84 rs2_gl_init_processing_glfw(RS2_API_VERSION, share_with, binding, use_glsl ? 1 : 0, &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:
123 yuy_decoder() : rs2::yuy_decoder(init()) { }
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 {
146 public:
147 y411_decoder() : rs2::y411_decoder( init() ) {}
148
149 private:
150 static std::shared_ptr<rs2_processing_block> init()
151 {
152 rs2_error* e = nullptr;
153 auto block = std::shared_ptr<rs2_processing_block>(
156 error::handle(e);
157
158 return block;
159 }
160 };
161
167 {
168 public:
169 colorizer() : rs2::colorizer(init()) { }
170
171 private:
172 std::shared_ptr<rs2_processing_block> init()
173 {
174 rs2_error* e = nullptr;
175 auto block = std::shared_ptr<rs2_processing_block>(
178 error::handle(e);
179
180 return block;
181 }
182 };
183
184 class uploader : public rs2::filter
185 {
186 public:
187 uploader() : rs2::filter(init()) { }
188
189 private:
190 std::shared_ptr<rs2_processing_block> init()
191 {
192 rs2_error* e = nullptr;
193 auto block = std::shared_ptr<rs2_processing_block>(
196 error::handle(e);
197 return block;
198 }
199 };
200
206 {
207 public:
208 pointcloud() : rs2::pointcloud(init()) {}
209
210 pointcloud(rs2_stream stream, int index = 0)
211 : rs2::pointcloud(init())
212 {
213 set_option(RS2_OPTION_STREAM_FILTER, float(stream));
215 }
216
217 private:
218 friend class context;
219
220 std::shared_ptr<rs2_processing_block> init()
221 {
222 rs2_error* e = nullptr;
223
224 auto block = std::shared_ptr<rs2_processing_block>(
227
228 error::handle(e);
229
230 return block;
231 }
232 };
233
240 {
241 public:
242 camera_renderer() : rs2::filter(init()) {}
243
244 void set_matrix(rs2_gl_matrix_type type, float* m4x4)
245 {
246 rs2_error* e = nullptr;
247 rs2_gl_set_matrix(get(), type, m4x4, &e);
248 error::handle(e);
249 }
250
256 private:
257 friend class context;
258
259 std::shared_ptr<rs2_processing_block> init()
260 {
261 rs2_error* e = nullptr;
262
263 auto block = std::shared_ptr<rs2_processing_block>(
266
267 error::handle(e);
268 return block;
269 }
270 };
271
279 {
280 public:
282
283 void set_matrix(rs2_gl_matrix_type type, float* m4x4)
284 {
285 rs2_error* e = nullptr;
286 rs2_gl_set_matrix(get(), type, m4x4, &e);
287 error::handle(e);
288 }
289
290 static const auto OPTION_FILLED = rs2_option(RS2_OPTION_COUNT + 1);
291 static const auto OPTION_SHADED = rs2_option(RS2_OPTION_COUNT + 2);
292
296
300
302 static const auto OPTION_SELECTED = rs2_option(RS2_OPTION_COUNT + 10);
304
305 static const auto OPTION_NORMAL_X = rs2_option(RS2_OPTION_COUNT + 12);
306 static const auto OPTION_NORMAL_Y = rs2_option(RS2_OPTION_COUNT + 13);
307 static const auto OPTION_NORMAL_Z = rs2_option(RS2_OPTION_COUNT + 14);
308
310
311 private:
312 friend class context;
313
314 std::shared_ptr<rs2_processing_block> init()
315 {
316 rs2_error* e = nullptr;
317
318 auto block = std::shared_ptr<rs2_processing_block>(
321
322 error::handle(e);
323 return block;
324 }
325 };
326
329 class align : public rs2::align
330 {
331 public:
332 align(rs2_stream to) : rs2::align(init(to)) {}
333
334 private:
335 friend class context;
336
337 std::shared_ptr<rs2_processing_block> init(rs2_stream to)
338 {
339 rs2_error* e = nullptr;
340
341 auto block = std::shared_ptr<rs2_processing_block>(
344
345 error::handle(e);
346
347 return block;
348 }
349 };
350 }
351}
352#endif // LIBREALSENSE_RS2_PROCESSING_GL_HPP
Definition rs_processing.hpp:709
Definition rs_processing.hpp:753
static void handle(rs2_error *e)
Definition rs_types.hpp:162
Definition rs_processing.hpp:362
filter(std::shared_ptr< rs2_processing_block > block, int queue_size=1)
Definition rs_processing.hpp:384
rs2_processing_block * get() const
Definition rs_processing.hpp:406
frame()
Definition rs_frame.hpp:351
rs2_frame * get() const
Definition rs_frame.hpp:592
friend class context
Definition rs_processing_gl.hpp:335
align(rs2_stream to)
Definition rs_processing_gl.hpp:332
static const auto OPTION_MOUSE_X
Definition rs_processing_gl.hpp:251
static const auto OPTION_SELECTED
Definition rs_processing_gl.hpp:255
static const auto OPTION_MOUSE_Y
Definition rs_processing_gl.hpp:252
camera_renderer()
Definition rs_processing_gl.hpp:242
friend class context
Definition rs_processing_gl.hpp:257
static const auto OPTION_MOUSE_PICK
Definition rs_processing_gl.hpp:253
void set_matrix(rs2_gl_matrix_type type, float *m4x4)
Definition rs_processing_gl.hpp:244
static const auto OPTION_WAS_PICKED
Definition rs_processing_gl.hpp:254
colorizer()
Definition rs_processing_gl.hpp:169
uint32_t get_texture_id(unsigned int id=0) const
Definition rs_processing_gl.hpp:107
gpu_frame(const frame &f)
Definition rs_processing_gl.hpp:96
static const auto OPTION_PICKED_Z
Definition rs_processing_gl.hpp:299
static const auto OPTION_NORMAL_Y
Definition rs_processing_gl.hpp:306
static const auto OPTION_SELECTED
Definition rs_processing_gl.hpp:302
static const auto OPTION_NORMAL_X
Definition rs_processing_gl.hpp:305
static const auto OPTION_ORIGIN_PICKED
Definition rs_processing_gl.hpp:303
void set_matrix(rs2_gl_matrix_type type, float *m4x4)
Definition rs_processing_gl.hpp:283
static const auto OPTION_PICKED_Y
Definition rs_processing_gl.hpp:298
pointcloud_renderer()
Definition rs_processing_gl.hpp:281
static const auto OPTION_MOUSE_PICK
Definition rs_processing_gl.hpp:295
static const auto OPTION_MOUSE_X
Definition rs_processing_gl.hpp:293
static const auto OPTION_FILLED
Definition rs_processing_gl.hpp:290
friend class context
Definition rs_processing_gl.hpp:312
static const auto OPTION_NORMAL_Z
Definition rs_processing_gl.hpp:307
static const auto OPTION_MOUSE_Y
Definition rs_processing_gl.hpp:294
static const auto OPTION_PICKED_X
Definition rs_processing_gl.hpp:297
static const auto OPTION_PICKED_ID
Definition rs_processing_gl.hpp:301
static const auto OPTION_SHADED
Definition rs_processing_gl.hpp:291
static const auto OPTION_SCALE_FACTOR
Definition rs_processing_gl.hpp:309
Definition rs_processing_gl.hpp:206
pointcloud(rs2_stream stream, int index=0)
Definition rs_processing_gl.hpp:210
pointcloud()
Definition rs_processing_gl.hpp:208
friend class context
Definition rs_processing_gl.hpp:218
uploader()
Definition rs_processing_gl.hpp:187
y411_decoder()
Definition rs_processing_gl.hpp:147
yuy_decoder()
Definition rs_processing_gl.hpp:123
void set_option(rs2_option option, float value) const
Definition rs_options.hpp:256
Definition rs_processing.hpp:431
Definition rs_processing.hpp:530
Definition rs_processing.hpp:501
Definition rs_processing_gl.hpp:15
void shutdown_processing()
Definition rs_processing_gl.hpp:61
void init_processing(bool use_glsl=true)
Definition rs_processing_gl.hpp:54
void init_rendering(bool use_glsl=true)
Definition rs_processing_gl.hpp:46
void shutdown_rendering()
Definition rs_processing_gl.hpp:19
Definition rs_processing_gl.hpp:13
#define RS2_API_VERSION
Definition rs.h:42
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls,...
Definition rs_option.h:27
@ RS2_OPTION_STREAM_FILTER
Definition rs_option.h:71
@ RS2_OPTION_COUNT
Definition rs_option.h:129
@ RS2_OPTION_STREAM_INDEX_FILTER
Definition rs_option.h:73
void rs2_delete_processing_block(rs2_processing_block *block)
Exposes RealSense processing-block functionality for GPU for C compilers.
rs2_processing_block * rs2_gl_create_colorizer(int api_version, rs2_error **error)
unsigned int rs2_gl_frame_get_texture_id(const rs2_frame *f, unsigned int id, rs2_error **error)
@ RS2_GL_EXTENSION_VIDEO_FRAME
Definition rs_processing_gl.h:24
rs2_processing_block * rs2_gl_create_pointcloud(int api_version, rs2_error **error)
struct GLFWwindow GLFWwindow
Definition rs_processing_gl.h:43
void rs2_gl_init_rendering(int api_version, int use_glsl, rs2_error **error)
rs2_processing_block * rs2_gl_create_yuy_decoder(int api_version, rs2_error **error)
rs2_processing_block * rs2_gl_create_align(int api_version, rs2_stream to, rs2_error **error)
void rs2_gl_set_matrix(rs2_processing_block *block, rs2_gl_matrix_type type, float *m4x4, rs2_error **error)
rs2_processing_block * rs2_gl_create_camera_renderer(int api_version, rs2_error **error)
void rs2_gl_shutdown_rendering(int api_version, rs2_error **error)
void rs2_gl_shutdown_processing(int api_version, rs2_error **error)
rs2_gl_matrix_type
Definition rs_processing_gl.h:34
int rs2_gl_is_frame_extendable_to(const rs2_frame *f, rs2_gl_extension extension_type, rs2_error **error)
rs2_processing_block * rs2_gl_create_uploader(int api_version, rs2_error **error)
rs2_processing_block * rs2_gl_create_y411_decoder(int api_version, rs2_error **error)
void rs2_gl_init_rendering_glfw(int api_version, glfw_binding bindings, int use_glsl, rs2_error **error)
void rs2_gl_init_processing(int api_version, int use_glsl, rs2_error **error)
void rs2_gl_init_processing_glfw(int api_version, GLFWwindow *share_with, glfw_binding bindings, int use_glsl, rs2_error **error)
rs2_processing_block * rs2_gl_create_pointcloud_renderer(int api_version, rs2_error **error)
rs2_stream
Streams are different types of data provided by RealSense devices.
Definition rs_sensor.h:44
struct rs2_error rs2_error
Definition rs_types.h:230
Definition rs_processing_gl.h:59