76 lines
2.7 KiB
C++
76 lines
2.7 KiB
C++
#include "application.h"
|
|
#include "modifier_helper.h"
|
|
#include "containers/overlay.h"
|
|
#include "containers/scroll_box/scroll_box.h"
|
|
#include "image/texture_manager.h"
|
|
#include "text/font_manager.h"
|
|
#include "widgets/imager.h"
|
|
#include "widgets/mask.h"
|
|
#include "widgets/post_process.h"
|
|
#include "widgets/text_widget.h"
|
|
#include "widgets/text_input/text_input.h"
|
|
|
|
using namespace mirage;
|
|
|
|
int main(int argc, char* argv[]) {
|
|
app::application app;
|
|
|
|
app::application_config config;
|
|
config.title = "Test Thread";
|
|
config.width = 800;
|
|
config.height = 600;
|
|
config.enable_multithreading = true;
|
|
config.enable_validation = true;
|
|
config.vsync = true;
|
|
|
|
if (!app.initialize(config)) {
|
|
return -1;
|
|
}
|
|
|
|
auto texture_id = app.texture_mgr()->load_texture("D:\\G2uY1fJa8AAOucs.jpg").value();
|
|
// auto texture_id = app.texture_mgr()->load_texture("D:\\screenshot-20251128-165627.png").value();
|
|
auto tex_size = app.texture_mgr()->get_texture(texture_id)->size().cast<float>();
|
|
|
|
// 加载字体
|
|
auto font_result = app.font_mgr()->load_font(R"(C:\Windows\Fonts\msyh.ttc)");
|
|
if (!font_result.has_value())
|
|
throw std::runtime_error("加载字体失败");
|
|
auto font_id = font_result.value();
|
|
|
|
auto root_widget = new_widget<scroll_box>()[
|
|
new_widget<text_widget>()->font_id(font_id).text("你好,我们在此相遇").font_size(24).tooltip("测试tooltip"),
|
|
new_widget<text_input>()->font_id(font_id).font_size(24),
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
// 圆形遮罩
|
|
new_widget<mask>()[
|
|
// 模糊效果 (blur)
|
|
new_widget<post_process>()->blur(40.0f)
|
|
]->circle() | align(alignment::center_left)
|
|
],
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
new_widget<post_process>()->vignette()
|
|
],
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
new_widget<post_process>()->chromatic_aberration(10, 1)
|
|
],
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
new_widget<post_process>()->noise(20.0f, 1.f, true)
|
|
],
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
new_widget<post_process>()->color_adjust(0.1f, 1.5f, 1.5f, 2.2f)
|
|
],
|
|
new_widget<overlay>()[
|
|
new_widget<imager>()->texture_id(texture_id).source_size(tex_size).scale(scale_mode::contain),
|
|
new_widget<post_process>()->color_tint(color::from_rgba(255, 100, 100, 255), 0.3f, blend_mode::overlay)
|
|
]
|
|
];
|
|
|
|
app.set_root_widget(root_widget.ptr());
|
|
app.run();
|
|
}
|