Files
mirage/example/src/main.cpp

58 lines
1.3 KiB
C++

//
// Created by Administrator on 25-2-26.
//
#include "mirage.h"
#include "window/mwindow.h"
#include "widget/compound_widget/mbutton.h"
#include "widget/panel_widget/mbox.h"
#include "pixel.h"
#include "misc/mapped_file/mapped_file.h"
#include "stb_image_loader.h"
#include "texture/texture2d.h"
#include "widget/widget_new.h"
#include "widget/leaf_widget/mimage.h"
int main(int argc, char* argv[]) {
mirage_app::get().init();
auto ii = std::make_shared<texture2d>();
{
auto file = mapped_file::create();
file->map_file(L"Z:/Root/Local/NanakoDisk/涩图/可爱偷猴计划/蕾米莉亚 & 芙兰朵露/1712938522333.jpg");
stb_image_loader image_loader;
image_loader.init(file->get_data(), file->get_size());
const auto& heap = image_loader.load();
texture2d_data data;
data.pixel_format = heap->info.get_pixel_format();
data.size = { heap->info.width, heap->info.height };
data.data_ptr = heap->data;
ii->create(data);
}
{
auto map = ii->map(texture_map_type::read);
map->read_only;
}
auto image2 = std::make_shared<mimage>();
image2->set_image(ii);
image2->set_sampler(sampler_type::linear_clamp);
const auto& window = mwindow::create({ 800, 600 }, L"Hello, World!");
window->set_content(
mnew(mh_box)
mslot(mh_box)
[
image2
].stretch()
);
mirage_app::get().run();
return 0;
}