8 #include "../proc/synthetic-stream.h"
18 #include <glad/glad.h>
35 void align_gl::cleanup_gpu_resources()
39 _other_texture.reset();
44 void align_gl::create_gpu_resources()
46 _renderer = std::make_shared<rs2::gl::pointcloud_renderer>();
47 _pc = std::make_shared<rs2::gl::pointcloud>();
48 _other_texture = std::make_shared<rs2::texture_buffer>();
49 _upload = std::make_shared<rs2::gl::uploader>();
50 _enabled = glsl_enabled() ? 1 : 0;
62 auto p = _pc->calculate(
depth);
66 throw std::runtime_error(
"Frame is not depth frame, cannot cast");
70 throw std::runtime_error(
"Frame is not gpu_addon_interface, cannot output texture");
77 throw std::runtime_error(
"Frame interface is not depth frame");
79 frame_ref->set_sensor(depth_ptr->get_sensor());
82 frame_ref->set_original(std::move(
h));
87 gf->get_gpu_section().output_texture(0, &aligned_tex, tex_type.type);
89 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
91 auto prof =
depth.get_profile();
98 aligned = _upload->process(aligned);
99 aligned = _upload->process(aligned);
104 int *viewport,
double alpha,
double beta,
double skew,
105 double u0,
double v0,
int img_width,
int img_height,
double near_clip,
double far_clip )
117 double N = near_clip;
131 ortho(0,0) = 2.f/(R-L); ortho(0,3) = float(-(R+L)/(R-L));
132 ortho(1,1) = 2.f/(T-B); ortho(1,3) = float(-(T+B)/(T-B));
133 ortho(2,2) = -2.f/float(F-N); ortho(2,3) = float(-(F+N)/(F-N));
141 tproj(0,0) = float(
alpha); tproj(0,1) = float(skew); tproj(0,2) = float(u0);
142 tproj(1,1) = float(
beta); tproj(1,2) = float(
v0);
143 tproj(2,2) = float(-(N+F)); tproj(2,3) = float(-N*F);
158 perform_gl_action([&] {
165 texture = input_frame.get_texture_id(0);
169 _other_texture->upload(tex, tex.get_profile().format());
170 texture = _other_texture->get_gl_handle();
180 width,
height, 0, textype.gl_format, textype.data_type,
nullptr);
201 projection(3, 2) *= -1.f;
202 projection(2, 3) *= -1.f;
203 projection(2, 2) *= -1.f;
212 for (
int i = 0;
i < 3;
i++)
214 for (
int j = 0;
j < 3;
j++)
221 _renderer->process(
model);
240 auto p = _pc->calculate(
depth);
245 throw std::runtime_error(
"Frame interface is not gpu addon interface");
251 gf->get_gpu_section().output_texture(0, &output_rgb, tex_type.type);
253 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
257 auto prof =
depth.get_profile();
259 auto extr = prof.get_extrinsics_to(prof);
260 render(
p, other,
intr,
extr, output_rgb);
268 auto opt = std::make_shared<librealsense::ptr_option<int>>(
269 0, 1, 0, 1, &
_enabled,
"GLSL enabled");
286 LOG_DEBUG(
"Error while cleaning up gpu resources" );