iridescence
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);
42 void set_backface_culling_range(const Eigen::Vector2f& range);
43
45 bool info_buffer_enabled() const;
48
49 const glk::Texture& color_buffer() const;
50 const glk::Texture& depth_buffer() const;
52 const glk::Texture& info_buffer() const;
54
56
57 void bind();
58 void unbind();
59
62
63 void render_to_screen(int color_buffer_id = 0);
64
65 Eigen::Vector4i pick_info(const Eigen::Vector2i& p, int window = 2) const;
66 float pick_depth(const Eigen::Vector2i& p, int window = 2) const;
67 Eigen::Vector3f unproject(const Eigen::Vector2i& p, float depth) const;
68
69 void draw_ui();
70
71public:
72 Eigen::Vector2i size;
73 Eigen::Vector4f clear_color;
74
78
82
84 Eigen::Vector2f backface_culling_range;
85
90
92
93 std::unique_ptr<glk::GLSLShader> shader;
94 std::unique_ptr<glk::GLSLShader> texture_shader;
95 std::unique_ptr<glk::GLSLShader> partial_clear_shader;
96 std::unique_ptr<glk::FrameBuffer> frame_buffer;
97 std::unique_ptr<glk::FrameBuffer> screen_effect_buffer;
98 std::shared_ptr<glk::ScreenEffect> screen_effect;
99 std::unique_ptr<glk::TextureRenderer> texture_renderer;
100 std::shared_ptr<glk::Texture> bg_texture;
101
102 std::unique_ptr<glk::Texture> colormap;
103 std::shared_ptr<guik::CameraControl> camera_control;
104 std::shared_ptr<guik::ProjectionControl> projection_control;
105};
106
107} // namespace guik
108
109#endif
Texture class to wrap OpenGL texture object.
Definition texture.hpp:11
const glk::Texture & color_buffer() const
std::shared_ptr< guik::ProjectionControl > projection_control
Definition gl_canvas.hpp:104
double partial_rendering_clear_thresh
Definition gl_canvas.hpp:88
std::unique_ptr< glk::TextureRenderer > texture_renderer
Definition gl_canvas.hpp:99
const glk::Texture & normal_buffer() const
Eigen::Vector2i size
Definition gl_canvas.hpp:72
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:86
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:81
GLenum alpha_blend_sfactor
Definition gl_canvas.hpp:75
void unbind_second()
const glk::Texture & depth_buffer() const
std::unique_ptr< glk::GLSLShader > shader
Definition gl_canvas.hpp:93
std::shared_ptr< guik::CameraControl > camera_control
Definition gl_canvas.hpp:103
void enable_normal_buffer()
std::unique_ptr< glk::GLSLShader > texture_shader
Definition gl_canvas.hpp:94
Eigen::Vector3f unproject(const Eigen::Vector2i &p, float depth) const
void enable_backface_culling()
void set_clear_color(const Eigen::Vector4f &color)
bool blend_depth_write
Definition gl_canvas.hpp:77
bool normal_buffer_enabled() const
const std::shared_ptr< glk::ScreenEffect > & get_effect() const
void set_blend_func(GLenum sfactor, GLenum dfactor)
bool backface_culling_enabled() const
Eigen::Vector2f backface_culling_range
Definition gl_canvas.hpp:84
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:97
bool partial_rendering_enabled() const
double keyboard_control_speed
Definition gl_canvas.hpp:91
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:100
bool is_backface_culling_enabled
Definition gl_canvas.hpp:83
const glk::Texture & info_buffer() const
std::shared_ptr< glk::ScreenEffect > screen_effect
Definition gl_canvas.hpp:98
bool clear_partial_rendering_flag
Definition gl_canvas.hpp:87
void disable_backface_culling()
Eigen::Vector4f clear_color
Definition gl_canvas.hpp:73
int normal_buffer_id
Definition gl_canvas.hpp:79
void bind_second()
std::unique_ptr< glk::FrameBuffer > frame_buffer
Definition gl_canvas.hpp:96
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:76
std::unique_ptr< glk::GLSLShader > partial_clear_shader
Definition gl_canvas.hpp:95
void clear_partial_rendering()
std::unique_ptr< glk::Texture > colormap
Definition gl_canvas.hpp:102
Eigen::Matrix4f last_projection_view_matrix
Definition gl_canvas.hpp:89
void set_backface_culling_range(const Eigen::Vector2f &range)
bool info_buffer_enabled() const
int info_buffer_id
Definition gl_canvas.hpp:80
COLORMAP
Definition colormap.hpp:9
Definition drawable_container.hpp:9