Go to the documentation of this file.
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");
67 void camera_shader::begin() { _shader->begin(); }
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;
135 for (
auto&
xyz :
mesh.positions)
149 auto i =
s.begin(),
j = prefix.begin();
150 for (;
i !=
s.end() &&
j != prefix.end() && *
i == *
j;
152 return j == prefix.end();
202 for (
auto&
i :
mesh.indexes)
210 glColor4f(opacity * 0.036
f, opacity * 0.044
f, opacity * 0.051
f, opacity);
@ RS2_GL_MATRIX_TRANSFORMATION
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)
GLsizei const GLchar *const * string
void register_option(rs2_option id, std::shared_ptr< option > option)
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
rs2::frame process_frame(const rs2::frame_source &source, const rs2::frame &f) override
std::shared_ptr< camera_shader > _shader
bool starts_with(const std::string &s, const std::string &prefix)
@ RS2_GL_MATRIX_PROJECTION
obj_mesh load_model(load_function f)
void uncompress_d435_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
static const char * fragment_shader_text
std::vector< std::unique_ptr< rs2::vao > > _camera_model
const rs2::matrix4 & get_matrix(rs2_gl_matrix_type type) const
@ RS2_OPTION_FILTER_MAGNITUDE
option & get_option(rs2_option id) override
static const char * vertex_shader_text
static std::unique_ptr< vao > create(const obj_mesh &m)
void(* load_function)(std::vector< rs2::float3 > &, std::vector< rs2::float3 > &, std::vector< short3 > &)
bool glsl_enabled() const
void perform_gl_action(T action)
std::vector< float3 > positions
GLdouble GLdouble GLint GLint GLdouble v1
virtual float query() const =0
std::vector< float3 > normals
std::vector< rs2::obj_mesh > camera_mesh
std::vector< int3 > indexes
void uncompress_d455_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
void uncompress_d415_obj(std::vector< float3 > &vertex_data, std::vector< float3 > &normals, std::vector< short3 > &index_data)
librealsense2
Author(s): LibRealSense ROS Team
autogenerated on Fri Aug 2 2024 08:30:01