Unravel Engine C++ Reference
Loading...
Searching...
No Matches
imgui_interface.cpp
Go to the documentation of this file.
1#include "imgui_interface.h"
2#include <editor/events.h>
3
4#include <engine/events.h>
6
7namespace unravel
8{
9
11{
12 auto& ev = ctx.get_cached<events>();
13
14 ev.on_os_event.connect(sentinel_, 1000, this, &imgui_interface::on_os_event);
15 ev.on_frame_render.connect(sentinel_, -100000, this, &imgui_interface::on_frame_ui_render);
16}
17
19{
20 if(inited_)
21 {
23 }
24}
25
27{
28 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
29
30 const auto& rend = ctx.get_cached<renderer>();
31 const auto& main_window = rend.get_main_window();
32 imguiCreate(main_window, 15.0f);
33
34 inited_ = true;
35 return true;
36}
37
39{
40 APPLOG_TRACE("{}::{}", hpp::type_name_str(*this), __func__);
41
42 return true;
43}
44
45void imgui_interface::on_os_event(rtti::context& ctx, os::event& e)
46{
48}
49
50void imgui_interface::on_frame_ui_render(rtti::context& ctx, delta_t dt)
51{
52 const auto& ev = ctx.get_cached<ui_events>();
53
54 const auto& rend = ctx.get_cached<renderer>();
55 const auto& main_window = rend.get_main_window();
56 const auto& main_surface = main_window->get_surface();
57
58 imguiBeginFrame(dt.count());
59
60 ev.on_frame_ui_render(ctx, dt);
61
62 gfx::render_pass pass("imgui_pass");
63 pass.bind(main_surface.get());
64 imguiEndFrame(pass.id);
65}
66
67} // namespace unravel
imgui_interface(rtti::context &ctx)
auto deinit(rtti::context &ctx) -> bool
auto init(rtti::context &ctx) -> bool
std::chrono::duration< float > delta_t
void imguiCreate(unravel::render_window *window, float _fontSize, bx::AllocatorI *_allocator)
Definition imgui.cpp:588
void imguiProcessEvent(os::event &e)
Definition imgui.cpp:598
void imguiBeginFrame(float dt)
Definition imgui.cpp:603
void imguiEndFrame(gfx::view_id id)
Definition imgui.cpp:609
void imguiDestroy()
Definition imgui.cpp:593
#define APPLOG_TRACE(...)
Definition logging.h:17
auto get_cached() -> T &
Definition context.hpp:49
hpp::event< void(rtti::context &, os::event &e)> on_os_event
os events
Definition events.h:34
auto get_main_window() const -> render_window *
Definition renderer.cpp:230