An Easy3D viewer with ImGui GUI support for custom rendering and input.
More...
#include <viewer_imgui.h>
|
| ViewerImGui (const std::string &title="Easy3D ViewerImGui", int samples=4, int gl_major=3, int gl_minor=2, bool full_screen=false, bool resizable=true, int depth_bits=24, int stencil_bits=8, int width=800, int height=600) |
| Constructor for ViewerImGui.
|
|
| ~ViewerImGui () override |
| Destructor. Cleans up ImGui and OpenGL resources.
|
|
|
void | init () override |
| Initializes ImGui and binds it to the OpenGL and GLFW context.
|
|
void | pre_draw () override |
| Called before rendering the scene.
|
|
void | post_draw () override |
| Called after rendering the scene.
|
|
void | post_resize (int w, int h) override |
| Handles window resize events.
|
|
bool | callback_event_cursor_pos (double x, double y) override |
| Handles mouse movement.
|
|
bool | callback_event_mouse_button (int button, int action, int modifiers) override |
| Handles mouse button events.
|
|
bool | callback_event_keyboard (int key, int action, int modifiers) override |
| Handles keyboard key events.
|
|
bool | callback_event_character (unsigned int codepoint) override |
| Handles character input events.
|
|
bool | callback_event_scroll (double dx, double dy) override |
| Handles mouse scroll events.
|
|
void | draw_menu_file () |
| Draws the "File" menu in the main menu bar.
|
|
void | draw_menu_view () |
| Draws the "View" menu in the main menu bar.
|
|
float | pixel_ratio () |
| Computes the pixel ratio between framebuffer and window size.
|
|
float | widget_scaling () |
| Calculates the widget scaling factor.
|
|
void | reload_font (int font_size=16) |
| Reloads the ImGui font at a given font size.
|
|
|
float | menu_height_ |
| Height of the menu bar, used for adjusting overlay positions.
|
|
|
static ImGuiContext * | context_ |
| Global ImGui context shared across all viewer instances.
|
|
An Easy3D viewer with ImGui GUI support for custom rendering and input.
This viewer integrates the Dear ImGui library into the Easy3D rendering pipeline, allowing the use of custom toolbars, overlays, and event handling in a platform-independent manner.
◆ ViewerImGui()
easy3d::ViewerImGui::ViewerImGui |
( |
const std::string & |
title = "Easy3D ViewerImGui" , |
|
|
int |
samples = 4 , |
|
|
int |
gl_major = 3 , |
|
|
int |
gl_minor = 2 , |
|
|
bool |
full_screen = false , |
|
|
bool |
resizable = true , |
|
|
int |
depth_bits = 24 , |
|
|
int |
stencil_bits = 8 , |
|
|
int |
width = 800 , |
|
|
int |
height = 600 |
|
) |
| |
|
explicit |
Constructor for ViewerImGui.
Initializes a viewer window with OpenGL and ImGui support.
- Parameters
-
title | Title of the application window. |
samples | Number of anti-aliasing samples. |
gl_major | Major version of OpenGL. |
gl_minor | Minor version of OpenGL. |
full_screen | Launch in fullscreen mode. |
resizable | Window resizable flag. |
depth_bits | Depth buffer precision. |
stencil_bits | Stencil buffer precision. |
width | Initial window width in pixels. |
height | Initial window height in pixels. |
◆ ~ViewerImGui()
easy3d::ViewerImGui::~ViewerImGui |
( |
| ) |
|
|
override |
Destructor. Cleans up ImGui and OpenGL resources.
◆ callback_event_character()
bool easy3d::ViewerImGui::callback_event_character |
( |
unsigned int |
codepoint | ) |
|
|
overrideprotected |
Handles character input events.
- Returns
- true if ImGui captures the input.
◆ callback_event_cursor_pos()
bool easy3d::ViewerImGui::callback_event_cursor_pos |
( |
double |
x, |
|
|
double |
y |
|
) |
| |
|
overrideprotected |
Handles mouse movement.
- Returns
- true if ImGui captures the input.
◆ callback_event_keyboard()
bool easy3d::ViewerImGui::callback_event_keyboard |
( |
int |
key, |
|
|
int |
action, |
|
|
int |
modifiers |
|
) |
| |
|
overrideprotected |
Handles keyboard key events.
- Returns
- true if ImGui captures the input.
◆ callback_event_mouse_button()
bool easy3d::ViewerImGui::callback_event_mouse_button |
( |
int |
button, |
|
|
int |
action, |
|
|
int |
modifiers |
|
) |
| |
|
overrideprotected |
Handles mouse button events.
- Returns
- true if ImGui captures the input.
◆ callback_event_scroll()
bool easy3d::ViewerImGui::callback_event_scroll |
( |
double |
dx, |
|
|
double |
dy |
|
) |
| |
|
overrideprotected |
Handles mouse scroll events.
- Returns
- true if ImGui captures the input.
◆ draw_menu_file()
void easy3d::ViewerImGui::draw_menu_file |
( |
| ) |
|
|
protected |
Draws the "File" menu in the main menu bar.
◆ draw_menu_view()
void easy3d::ViewerImGui::draw_menu_view |
( |
| ) |
|
|
protected |
Draws the "View" menu in the main menu bar.
◆ init()
void easy3d::ViewerImGui::init |
( |
| ) |
|
|
overrideprotected |
Initializes ImGui and binds it to the OpenGL and GLFW context.
◆ pixel_ratio()
float easy3d::ViewerImGui::pixel_ratio |
( |
| ) |
|
|
protected |
Computes the pixel ratio between framebuffer and window size.
Useful for supporting HiDPI displays.
- Returns
- Pixel ratio (usually 1.0 for standard DPI).
◆ post_draw()
void easy3d::ViewerImGui::post_draw |
( |
| ) |
|
|
overrideprotected |
Called after rendering the scene.
Draws ImGui widgets, menus, and overlays (e.g., logo and FPS).
◆ post_resize()
void easy3d::ViewerImGui::post_resize |
( |
int |
w, |
|
|
int |
h |
|
) |
| |
|
overrideprotected |
Handles window resize events.
Updates ImGui's display size.
- Parameters
-
w | New window width. |
h | New window height. |
◆ pre_draw()
void easy3d::ViewerImGui::pre_draw |
( |
| ) |
|
|
overrideprotected |
Called before rendering the scene.
Prepares a new ImGui frame.
◆ reload_font()
void easy3d::ViewerImGui::reload_font |
( |
int |
font_size = 16 | ) |
|
|
protected |
Reloads the ImGui font at a given font size.
This clears the font atlas and applies new scaling.
- Parameters
-
font_size | Desired font size (default = 16). |
◆ widget_scaling()
float easy3d::ViewerImGui::widget_scaling |
( |
| ) |
|
|
inlineprotected |
Calculates the widget scaling factor.
This accounts for DPI scaling and pixel ratio.
- Returns
- Scaling factor for ImGui widgets.
◆ context_
ImGuiContext* easy3d::ViewerImGui::context_ |
|
staticprotected |
Global ImGui context shared across all viewer instances.
Can be overridden to support per-window contexts, but not typical.
◆ menu_height_
float easy3d::ViewerImGui::menu_height_ |
|
protected |
Height of the menu bar, used for adjusting overlay positions.
The documentation for this class was generated from the following file: