gtsam_points
Loading...
Searching...
No Matches
gl_canvas.hpp
Go to the documentation of this file.
1#ifndef GLK_GL_CANVAS_CANVAS_HPP
2#define GLK_GL_CANVAS_CANVAS_HPP
3
4#include <imgui.h>
5
6#include <glk/colormap.hpp>
7#include <glk/glsl_shader.hpp>
11
14
15namespace guik {
16
17class GLCanvas {
18public:
19 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
20
21 GLCanvas(const Eigen::Vector2i& size, const std::string& shader_name = "rainbow", size_t num_color_buffers = 1);
22
23 bool ready() const;
24 bool load_shader(const std::string& shader_name);
25
26 void set_size(const Eigen::Vector2i& size);
27 void set_clear_color(const Eigen::Vector4f& color);
28 void set_colormap(glk::COLORMAP colormap_type);
29 void set_effect(const std::shared_ptr<glk::ScreenEffect>& effect);
30 const std::shared_ptr<glk::ScreenEffect>& get_effect() const;
31 void set_bg_texture(const std::shared_ptr<glk::Texture>& bg_texture);
32 void set_blend_func(GLenum sfactor, GLenum dfactor);
34
37 void enable_partial_rendering(double clear_thresh = 1e-6);
40
42 bool info_buffer_enabled() const;
44
45 const glk::Texture& color_buffer() const;
46 const glk::Texture& depth_buffer() const;
48 const glk::Texture& info_buffer() const;
50
52
53 void bind();
54 void unbind();
55
58
59 void render_to_screen(int color_buffer_id = 0);
60
61 Eigen::Vector4i pick_info(const Eigen::Vector2i& p, int window = 2) const;
62 float pick_depth(const Eigen::Vector2i& p, int window = 2) const;
63 Eigen::Vector3f unproject(const Eigen::Vector2i& p, float depth) const;
64
65 void draw_ui();
66
67public:
68 Eigen::Vector2i size;
69 Eigen::Vector4f clear_color;
70
74
78
83
85
86 std::unique_ptr<glk::GLSLShader> shader;
87 std::unique_ptr<glk::GLSLShader> texture_shader;
88 std::unique_ptr<glk::GLSLShader> partial_clear_shader;
89 std::unique_ptr<glk::FrameBuffer> frame_buffer;
90 std::unique_ptr<glk::FrameBuffer> screen_effect_buffer;
91 std::shared_ptr<glk::ScreenEffect> screen_effect;
92 std::unique_ptr<glk::TextureRenderer> texture_renderer;
93 std::shared_ptr<glk::Texture> bg_texture;
94
95 std::unique_ptr<glk::Texture> colormap;
96 std::shared_ptr<guik::CameraControl> camera_control;
97 std::shared_ptr<guik::ProjectionControl> projection_control;
98};
99
100} // namespace guik
101
102#endif
Definition texture.hpp:10
Definition gl_canvas.hpp:17
const glk::Texture & color_buffer() const
std::shared_ptr< guik::ProjectionControl > projection_control
Definition gl_canvas.hpp:97
double partial_rendering_clear_thresh
Definition gl_canvas.hpp:81
std::unique_ptr< glk::TextureRenderer > texture_renderer
Definition gl_canvas.hpp:92
const glk::Texture & normal_buffer() const
Eigen::Vector2i size
Definition gl_canvas.hpp:68
void enable_partial_rendering(double clear_thresh=1e-6)
void set_blend_depth_write(bool blend_depth_write)
void set_colormap(glk::COLORMAP colormap_type)
bool is_partial_rendering_enabled
Definition gl_canvas.hpp:79
bool ready() const
void enable_info_buffer()
bool load_shader(const std::string &shader_name)
void set_bg_texture(const std::shared_ptr< glk::Texture > &bg_texture)
void disable_partial_rendering()
int dynamic_flag_buffer_id
Definition gl_canvas.hpp:77
GLenum alpha_blend_sfactor
Definition gl_canvas.hpp:71
void unbind_second()
const glk::Texture & depth_buffer() const
std::unique_ptr< glk::GLSLShader > shader
Definition gl_canvas.hpp:86
std::shared_ptr< guik::CameraControl > camera_control
Definition gl_canvas.hpp:96
void enable_normal_buffer()
std::unique_ptr< glk::GLSLShader > texture_shader
Definition gl_canvas.hpp:87
Eigen::Vector3f unproject(const Eigen::Vector2i &p, float depth) const
void set_clear_color(const Eigen::Vector4f &color)
bool blend_depth_write
Definition gl_canvas.hpp:73
bool normal_buffer_enabled() const
const std::shared_ptr< glk::ScreenEffect > & get_effect() const
void set_blend_func(GLenum sfactor, GLenum dfactor)
void render_to_screen(int color_buffer_id=0)
float pick_depth(const Eigen::Vector2i &p, int window=2) const
void set_size(const Eigen::Vector2i &size)
std::unique_ptr< glk::FrameBuffer > screen_effect_buffer
Definition gl_canvas.hpp:90
bool partial_rendering_enabled() const
double keyboard_control_speed
Definition gl_canvas.hpp:84
void mouse_control()
void set_effect(const std::shared_ptr< glk::ScreenEffect > &effect)
const glk::Texture & dynamic_flag_buffer() const
std::shared_ptr< glk::Texture > bg_texture
Definition gl_canvas.hpp:93
const glk::Texture & info_buffer() const
std::shared_ptr< glk::ScreenEffect > screen_effect
Definition gl_canvas.hpp:91
bool clear_partial_rendering_flag
Definition gl_canvas.hpp:80
Eigen::Vector4f clear_color
Definition gl_canvas.hpp:69
int normal_buffer_id
Definition gl_canvas.hpp:75
void bind_second()
std::unique_ptr< glk::FrameBuffer > frame_buffer
Definition gl_canvas.hpp:89
Eigen::Vector4i pick_info(const Eigen::Vector2i &p, int window=2) const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW GLCanvas(const Eigen::Vector2i &size, const std::string &shader_name="rainbow", size_t num_color_buffers=1)
GLenum alpha_blend_dfactor
Definition gl_canvas.hpp:72
std::unique_ptr< glk::GLSLShader > partial_clear_shader
Definition gl_canvas.hpp:88
void clear_partial_rendering()
std::unique_ptr< glk::Texture > colormap
Definition gl_canvas.hpp:95
Eigen::Matrix4f last_projection_view_matrix
Definition gl_canvas.hpp:82
bool info_buffer_enabled() const
int info_buffer_id
Definition gl_canvas.hpp:76
COLORMAP
Definition colormap.hpp:9
Definition drawable_container.hpp:9