Added raylib+rmlui template

This commit is contained in:
2026-08-23 20:57:32 -05:00
commit 1a378aebf0
15 changed files with 685 additions and 0 deletions

51
src/Application.cpp Normal file
View File

@@ -0,0 +1,51 @@
#include "Application.h"
#include "backend/RaylibInput.h"
#include <raylib.h>
#include <RmlUi/Core.h>
#include <RmlUi/Debugger.h>
bool Application::Init(int width, int height, const char* title, const char* documentPath) {
InitWindow(width, height, title);
SetTargetFPS(60);
Rml::SetSystemInterface(&system_interface);
Rml::SetRenderInterface(&render_interface);
Rml::Initialise();
context = Rml::CreateContext("main", Rml::Vector2i(width, height));
Rml::Debugger::Initialise(context);
// TODO: load a real font
if (Rml::ElementDocument* document = context->LoadDocument(documentPath)) {
document->Show();
} else {
TraceLog(LOG_WARNING, "Failed to load %s", documentPath);
}
return true;
}
void Application::Frame() {
if (WindowShouldClose()) {
running = false;
return;
}
ForwardInputToRml(context);
context->Update();
BeginDrawing();
ClearBackground(DARKGRAY);
// --- game world rendering goes here, before the UI ---
context->Render();
EndDrawing();
}
void Application::Shutdown() {
Rml::Shutdown();
CloseWindow();
}