8 #include "../proc/synthetic-stream.h" 18 #include <glad/glad.h> 36 void align_gl::cleanup_gpu_resources()
40 _other_texture.reset();
45 void align_gl::create_gpu_resources()
47 _renderer = std::make_shared<rs2::gl::pointcloud_renderer>();
48 _pc = std::make_shared<rs2::gl::pointcloud>();
49 _other_texture = std::make_shared<rs2::texture_buffer>();
50 _upload = std::make_shared<rs2::gl::uploader>();
51 _enabled = glsl_enabled() ? 1 : 0;
63 auto p = _pc->calculate(depth);
72 frame_ref->
set_sensor(depth_ptr->get_sensor());
80 gf->get_gpu_section().output_texture(0, &aligned_tex, tex_type.type);
82 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
86 auto extr = prof.get_extrinsics_to(other_profile);
88 render(
p, depth,
intr,
extr, aligned_tex);
91 aligned = _upload->process(aligned);
92 aligned = _upload->process(aligned);
97 int *viewport,
double alpha,
double beta,
double skew,
110 double N = near_clip;
124 ortho(0,0) = 2.f/(R-L); ortho(0,3) = float(-(R+L)/(R-L));
125 ortho(1,1) = 2.f/(T-B); ortho(1,3) = float(-(T+B)/(T-B));
126 ortho(2,2) = -2.f/float(F-N); ortho(2,3) = float(-(F+N)/(F-N));
134 tproj(0,0) = float(alpha); tproj(0,1) = float(skew); tproj(0,2) = 0.f;
135 tproj(1,1) = float(beta); tproj(1,2) = float(v0);
136 tproj(2,2) = float(-(N+F)); tproj(2,3) = float(-N*F);
142 frustum = ortho*tproj;
151 perform_gl_action([&] {
158 texture = input_frame.get_texture_id(0);
162 _other_texture->upload(tex, tex.get_profile().format());
163 texture = _other_texture->get_gl_handle();
173 width,
height, 0, textype.gl_format, textype.data_type,
nullptr);
194 projection(3, 2) *= -1.f;
195 projection(2, 3) *= -1.f;
196 projection(2, 2) *= -1.f;
205 for (
int i = 0;
i < 3;
i++)
207 for (
int j = 0;
j < 3;
j++)
214 _renderer->process(model);
233 auto p = _pc->calculate(depth);
242 gf->get_gpu_section().output_texture(0, &output_rgb, tex_type.type);
244 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
250 auto extr = prof.get_extrinsics_to(prof);
251 render(
p, other,
intr,
extr, output_rgb);
259 auto opt = std::make_shared<librealsense::ptr_option<int>>(
260 0, 1, 0, 1, &
_enabled,
"GLSL enabled");
#define GL_TEXTURE_MAG_FILTER
static matrix4 identity()
void add_extension(rs2_extension ex)
rs2_format format() const
void build_opengl_projection_for_intrinsics(matrix4 &frustum, int *viewport, double alpha, double beta, double skew, double u0, double v0, int img_width, int img_height, double near_clip, double far_clip)
matrix4 frustum(float left, float right, float bottom, float top, float zNear, float zFar, float ox, float oy)
texture_mapping & rs_format_to_gl_format(rs2_format type)
GLint GLint GLsizei GLsizei GLsizei depth
#define GL_TEXTURE_WRAP_T
void register_option(rs2_option id, std::shared_ptr< option > option)
GLfloat GLfloat GLfloat alpha
#define GL_COLOR_BUFFER_BIT
#define glBindFramebuffer
GLint GLsizei GLsizei height
GLint GLint GLsizei GLint GLenum format
void set_size(uint32_t width, uint32_t height, bool preloaded=false)
#define GL_TEXTURE_MIN_FILTER
void cleanup_gpu_resources() override
rs2_stream
Streams are different types of data provided by RealSense devices.
void set_sensor(std::shared_ptr< sensor_interface > s) override
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
void createTextureAttachment(uint32_t texture)
#define RS2_EXTENSION_VIDEO_FRAME_GL
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
void perform_gl_action(T action, S fallback)
virtual gpu_section & get_gpu_section()=0
typename ::boost::move_detail::remove_reference< T >::type && move(T &&t) BOOST_NOEXCEPT
#define RS2_EXTENSION_DEPTH_FRAME_GL
#define GL_COLOR_ATTACHMENT0
void to_column_major(float column_major[16])
rs2_intrinsics get_intrinsics() const
#define GL_TEXTURE_WRAP_S
stream_profile get_profile() const