74 lines
1.7 KiB
C++
74 lines
1.7 KiB
C++
#include <print>
|
|
#include <thread>
|
|
#include <chrono>
|
|
#include <RmlUi/Core.h>
|
|
#include <RmlUi/Debugger.h>
|
|
#include <RmlUi_Backend.h>
|
|
#include <RmlUi_Include_Windows.h>
|
|
|
|
void LoadFonts()
|
|
{
|
|
const Rml::String directory = "assets/";
|
|
|
|
struct FontFace {
|
|
const char* filename;
|
|
bool fallback_face;
|
|
};
|
|
FontFace font_faces[] = {
|
|
{"LatoLatin-Regular.ttf", false},
|
|
{"LatoLatin-Italic.ttf", false},
|
|
{"LatoLatin-Bold.ttf", false},
|
|
{"LatoLatin-BoldItalic.ttf", false},
|
|
{"NotoEmoji-Regular.ttf", true},
|
|
};
|
|
|
|
for (const FontFace& face : font_faces)
|
|
Rml::LoadFontFace(directory + face.filename, face.fallback_face);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
const int window_width = 1024;
|
|
const int window_height = 768;
|
|
|
|
if (!Backend::Initialize("Load Document Sample", window_width, window_height, true))
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
Rml::SetSystemInterface(Backend::GetSystemInterface());
|
|
Rml::SetRenderInterface(Backend::GetRenderInterface());
|
|
Rml::Initialise();
|
|
|
|
Rml::Context* context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height));
|
|
if (!context)
|
|
{
|
|
Rml::Shutdown();
|
|
Backend::Shutdown();
|
|
return -1;
|
|
}
|
|
|
|
LoadFonts();
|
|
|
|
if (Rml::ElementDocument* document = context->LoadDocument("assets/demo.rml"))
|
|
{
|
|
document->Show();
|
|
}
|
|
|
|
bool running = true;
|
|
while (running)
|
|
{
|
|
// Handle input and window events.
|
|
running = Backend::ProcessEvents(context);
|
|
context->Update();
|
|
Backend::BeginFrame();
|
|
context->Render();
|
|
Backend::PresentFrame();
|
|
}
|
|
|
|
Rml::Shutdown();
|
|
Backend::Shutdown();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|