pc-shader.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2019 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include "rendering.h"
7 #include "opengl3.h"
8 #include "synthetic-stream-gl.h"
10 
11 namespace librealsense
12 {
13  namespace gl
14  {
15 #pragma pack(push, 1)
16  struct rgba8 { uint8_t r, g, b, a; };
17  struct half4 { uint16_t x, y, z, w; };
18 #pragma pack(pop)
19 
21  {
22  public:
23  pointcloud_shader(const char* vertex_shader, const char* fragment_shader);
24 
25  void begin();
26  void end();
27 
28  void set_mvp(const rs2::matrix4& model,
29  const rs2::matrix4& view,
30  const rs2::matrix4& projection);
31 
32 
33  int texture_slot() const { return 0; }
34  int geometry_slot() const { return 1; }
35  int uvs_slot() const { return 2; }
36 
37  void set_image_size(int width, int height);
38  void set_min_delta_z(float min_delta_z);
39  void set_picked_id(float pid);
40  void set_shaded(bool shaded);
41  protected:
42  pointcloud_shader(std::unique_ptr<rs2::shader_program> shader);
43 
44  std::unique_ptr<rs2::shader_program> _shader;
45 
46  private:
47  void init();
48 
52 
53  uint32_t _width_location, _height_location;
57  };
58 
60  public gpu_rendering_object,
61  public matrix_container
62  {
63  public:
65  ~pointcloud_renderer() override;
66 
67  static const auto OPTION_FILLED = rs2_option(RS2_OPTION_COUNT + 1);
68  static const auto OPTION_SHADED = rs2_option(RS2_OPTION_COUNT + 2);
69 
70  static const auto OPTION_MOUSE_X = rs2_option(RS2_OPTION_COUNT + 3);
71  static const auto OPTION_MOUSE_Y = rs2_option(RS2_OPTION_COUNT + 4);
72  static const auto OPTION_MOUSE_PICK = rs2_option(RS2_OPTION_COUNT + 5);
73 
74  static const auto OPTION_PICKED_X = rs2_option(RS2_OPTION_COUNT + 6);
75  static const auto OPTION_PICKED_Y = rs2_option(RS2_OPTION_COUNT + 7);
76  static const auto OPTION_PICKED_Z = rs2_option(RS2_OPTION_COUNT + 8);
77 
78  static const auto OPTION_PICKED_ID = rs2_option(RS2_OPTION_COUNT + 9);
79 
80  static const auto OPTION_SELECTED = rs2_option(RS2_OPTION_COUNT + 10);
81  static const auto OPTION_ORIGIN_PICKED = rs2_option(RS2_OPTION_COUNT + 11);
82 
83  static const auto OPTION_NORMAL_X = rs2_option(RS2_OPTION_COUNT + 12);
84  static const auto OPTION_NORMAL_Y = rs2_option(RS2_OPTION_COUNT + 13);
85  static const auto OPTION_NORMAL_Z = rs2_option(RS2_OPTION_COUNT + 14);
86 
87  static const auto OPTION_SCALE_FACTOR = rs2_option(RS2_OPTION_COUNT + 15);
88 
89  void cleanup_gpu_resources() override;
90  void create_gpu_resources() override;
91 
92  rs2::frame process_frame(const rs2::frame_source& source, const rs2::frame& f) override;
93 
94  private:
95  std::shared_ptr<pointcloud_shader> _shader;
96  std::shared_ptr<pointcloud_shader> _pick_shader;
97  std::shared_ptr<rs2::vao> _model;
98  std::shared_ptr<rs2::texture_buffer> _vertex_texture;
99  std::shared_ptr<rs2::texture_buffer> _uvs_texture;
100  std::shared_ptr<rs2::texture_visualizer> _viz;
101  std::shared_ptr<rs2::fbo> _fbo;
102  int _width = 0;
103  int _height = 0;
104  option *_filled_opt, *_mouse_x_opt, *_mouse_y_opt, *_mouse_pick_opt,
105  *_picked_id_opt, *_picked_x_opt, *_picked_y_opt, *_picked_z_opt,
106  *_selected_opt, *_shaded_opt, *_origin_picked_opt,
107  *_normal_x_opt, *_normal_y_opt, *_normal_z_opt, *_scale_factor_opt;
110 
114  std::deque<std::chrono::high_resolution_clock::time_point> _durations;
115  };
116  }
117 }
GLuint GLuint end
GLint y
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
std::shared_ptr< pointcloud_shader > _shader
Definition: pc-shader.h:95
std::shared_ptr< rs2::texture_buffer > _vertex_texture
Definition: pc-shader.h:98
unsigned short uint16_t
Definition: stdint.h:79
GLdouble GLdouble GLdouble w
unsigned char uint8_t
Definition: stdint.h:78
not_this_one begin(...)
GLdouble f
std::shared_ptr< pointcloud_shader > _pick_shader
Definition: pc-shader.h:96
GLdouble x
unsigned int uint32_t
Definition: stdint.h:80
std::shared_ptr< rs2::vao > _model
Definition: pc-shader.h:97
GLint GLsizei GLsizei height
std::shared_ptr< rs2::fbo > _fbo
Definition: pc-shader.h:101
void init(void)
Definition: boing.c:180
std::shared_ptr< rs2::texture_buffer > _uvs_texture
Definition: pc-shader.h:99
std::shared_ptr< rs2::texture_visualizer > _viz
Definition: pc-shader.h:100
GLsizei GLsizei GLchar * source
GLuint shader
std::deque< std::chrono::high_resolution_clock::time_point > _durations
Definition: pc-shader.h:114
GLint GLsizei width
std::unique_ptr< rs2::shader_program > _shader
Definition: pc-shader.h:44


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