24 "attribute vec3 position;\n" 25 "uniform mat4 transformationMatrix;\n" 26 "uniform mat4 projectionMatrix;\n" 27 "uniform mat4 cameraMatrix;\n" 30 " vec4 worldPosition = transformationMatrix * vec4(position.xyz, 1.0);\n" 31 " gl_Position = projectionMatrix * cameraMatrix * worldPosition;\n" 36 "uniform float opacity;" 39 " gl_FragColor = vec4(opacity * (36.0 / 1000.0), opacity * (44.0 / 1000.0), opacity * (51.0 / 1000.0), opacity);\n" 48 camera_shader::camera_shader()
59 _shader->bind_attribute(0,
"position");
61 _transformation_matrix_location = _shader->get_uniform_location(
"transformationMatrix");
62 _projection_matrix_location = _shader->get_uniform_location(
"projectionMatrix");
63 _camera_matrix_location = _shader->get_uniform_location(
"cameraMatrix");
64 _opacity_location = _shader->get_uniform_location(
"opacity");
74 _shader->load_uniform(_transformation_matrix_location, model);
75 _shader->load_uniform(_camera_matrix_location, view);
76 _shader->load_uniform(_projection_matrix_location, projection);
79 void camera_shader::set_opacity(
float opacity)
81 _shader->load_uniform(_opacity_location, opacity);
84 void camera_renderer::cleanup_gpu_resources()
87 _camera_model.clear();
90 void camera_renderer::create_gpu_resources()
94 _shader = std::make_shared<camera_shader>();
96 for (
auto&&
mesh : camera_mesh)
103 camera_renderer::~camera_renderer()
105 perform_gl_action([&]()
107 cleanup_gpu_resources();
112 std::vector<rs2::float3>&, std::vector<short3>&);
117 std::vector<short3>
idx;
137 for (
auto&
xyz :
mesh.positions)
151 auto i = s.begin(),
j = prefix.begin();
152 for (;
i != s.end() &&
j != prefix.end() && *
i == *
j;
154 return j == prefix.end();
168 if (
starts_with(dev_name,
"Intel RealSense D415")) index = 0;
169 if (
starts_with(dev_name,
"Intel RealSense D435")) index = 1;
170 if (
starts_with(dev_name,
"Intel RealSense SR30")) index = 2;
171 if (
starts_with(dev_name,
"Intel RealSense T26")) index = 3;
172 if (
starts_with(dev_name,
"Intel RealSense L5")) index = 4;
206 for (
auto&
i :
mesh.indexes)
214 glColor4f(opacity * 0.036f, opacity * 0.044f, opacity * 0.051f, opacity);
std::vector< float3 > positions
static const char * fragment_shader_text
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
static std::unique_ptr< vao > create(const obj_mesh &m)
void uncompress_d415_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
void perform_gl_action(T action)
void uncompress_d435_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
option & get_option(rs2_option id) override
virtual float query() const =0
void uncompress_L515_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
void register_option(rs2_option id, std::shared_ptr< option > option)
bool starts_with(const std::string &s, const std::string &prefix)
obj_mesh load_model(load_function f)
std::vector< float3 > normals
bool glsl_enabled() const
void uncompress_t265_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
static const char * vertex_shader_text
std::vector< std::unique_ptr< rs2::vao > > _camera_model
const rs2::matrix4 & get_matrix(rs2_gl_matrix_type type) const
GLdouble GLdouble GLint GLint GLdouble v1
std::vector< int3 > indexes
static std::unique_ptr< shader_program > load(const std::string &vertex_shader, const std::string &fragment_shader, const char *input0=nullptr, const char *input1=nullptr, const char *output0=nullptr, const char *output1=nullptr)
void uncompress_sr305_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
std::vector< rs2::obj_mesh > camera_mesh
std::shared_ptr< camera_shader > _shader
void(* load_function)(std::vector< rs2::float3 > &, std::vector< rs2::float3 > &, std::vector< short3 > &)