4 #include "../include/librealsense2/hpp/rs_sensor.hpp" 5 #include "../include/librealsense2/hpp/rs_processing.hpp" 6 #include "../include/librealsense2-gl/rs_processing_gl.hpp" 16 #include <glad/glad.h> 34 void align_gl::cleanup_gpu_resources()
38 _other_texture.reset();
43 void align_gl::create_gpu_resources()
45 _renderer = std::make_shared<rs2::gl::pointcloud_renderer>();
46 _pc = std::make_shared<rs2::gl::pointcloud>();
47 _other_texture = std::make_shared<rs2::texture_buffer>();
48 _upload = std::make_shared<rs2::gl::uploader>();
49 _enabled = glsl_enabled() ? 1 : 0;
61 auto p = _pc->calculate(depth);
70 frame_ref->
set_sensor(depth_ptr->get_sensor());
78 gf->get_gpu_section().output_texture(0, &aligned_tex, tex_type.type);
80 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
84 auto extr = prof.get_extrinsics_to(other_profile);
86 render(
p, depth,
intr,
extr, aligned_tex);
89 aligned = _upload->process(aligned);
90 aligned = _upload->process(aligned);
95 int *viewport,
double alpha,
double beta,
double skew,
108 double N = near_clip;
122 ortho(0,0) = 2.f/(R-L); ortho(0,3) = float(-(R+L)/(R-L));
123 ortho(1,1) = 2.f/(T-B); ortho(1,3) = float(-(T+B)/(T-B));
124 ortho(2,2) = -2.f/float(F-N); ortho(2,3) = float(-(F+N)/(F-N));
132 tproj(0,0) = float(alpha); tproj(0,1) = float(skew); tproj(0,2) = 0.f;
133 tproj(1,1) = float(beta); tproj(1,2) = float(v0);
134 tproj(2,2) = float(-(N+F)); tproj(2,3) = float(-N*F);
140 frustum = ortho*tproj;
149 perform_gl_action([&] {
156 texture = input_frame.get_texture_id(0);
160 _other_texture->upload(tex, tex.get_profile().format());
161 texture = _other_texture->get_gl_handle();
171 width,
height, 0, textype.gl_format, textype.data_type,
nullptr);
192 projection(3, 2) *= -1.f;
193 projection(2, 3) *= -1.f;
194 projection(2, 2) *= -1.f;
203 for (
int i = 0;
i < 3;
i++)
205 for (
int j = 0;
j < 3;
j++)
212 _renderer->process(model);
231 auto p = _pc->calculate(depth);
240 gf->get_gpu_section().output_texture(0, &output_rgb, tex_type.type);
242 width,
height, 0, tex_type.gl_format, tex_type.data_type,
nullptr);
248 auto extr = prof.get_extrinsics_to(prof);
249 render(
p, other,
intr,
extr, output_rgb);
257 auto opt = std::make_shared<librealsense::ptr_option<int>>(
258 0, 1, 0, 1, &
_enabled,
"GLSL enabled");
#define GL_TEXTURE_MAG_FILTER
static matrix4 identity()
void add_extension(rs2_extension ex)
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)
stream_profile get_profile() const
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
GLfloat GLfloat GLfloat GLfloat h
#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_intrinsics get_intrinsics() const
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...
rs2_format format() const
void createTextureAttachment(uint32_t texture)
#define RS2_EXTENSION_VIDEO_FRAME_GL
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
GLenum GLenum GLenum input
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])
#define GL_TEXTURE_WRAP_S