MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / main

Function main

samples/application/ogui2/sandbox/src/sandbox_exmaple.cpp:29–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#include "SkrGui/widgets/mouse_region.hpp"
28
29int main(void)
30{
31 using namespace skr::gui;
32
33 // log system
34 skr::log::LogConstants::gFlushBehavior = skr::log::LogFlushBehavior::kFlushImmediate;
35
36 // create backends
37 SkrNativeDevice* device = SkrNew<SkrNativeDevice>();
38 device->init();
39
40 // create sandbox
41 Sandbox* sandbox = SkrNew<Sandbox>(device);
42 sandbox->init();
43
44 // setup content
45 {
46 auto widget = SNewWidget(Counter){};
47 sandbox->set_content(widget);
48 }
49
50 // input system
51 skr::input::InputSystem* input_system = nullptr;
52 {
53 // init input system
54 skr::input::Input::Initialize();
55 input_system = skr::input::InputSystem::Create();
56
57 // create mapping context
58 auto mapping_ctx = input_system->create_mapping_context();
59 input_system->add_mapping_context(mapping_ctx, 0, {});
60
61 // bind events
62 bind_pointer_event(input_system, mapping_ctx, sandbox);
63 }
64
65 // handler
66 bool b_quit = false;
67 auto handler = skr_system_get_default_handler();
68 handler->add_window_close_handler(
69 +[](SWindowHandle window, void* pQuit) {
70 bool& quit = *(bool*)pQuit;
71 quit = true;
72 },
73 &b_quit);
74 handler->add_window_resize_handler(
75 +[](SWindowHandle window, int32_t w, int32_t h, void* usr_data) {
76 auto sandbox = reinterpret_cast<Sandbox*>(usr_data);
77 sandbox->resize_window(w, h);
78 },
79 sandbox);
80
81 // show window
82 {
83 WindowDesc desc = {};
84 desc.size = { 600, 600 };
85 desc.pos = { 300, 300 };
86 desc.name = u8"SkrGUI Sandbox";

Callers

nothing calls this directly

Calls 15

InitializeFunction · 0.85
bind_pointer_eventFunction · 0.85
SkrDeleteFunction · 0.85
set_contentMethod · 0.80
add_mapping_contextMethod · 0.80
resize_windowMethod · 0.80
pump_messagesMethod · 0.80
process_messagesMethod · 0.80
render_all_windowsMethod · 0.80
CreateFunction · 0.50

Tested by

no test coverage detected