Inital commit

This commit is contained in:
2026-07-11 17:01:42 -05:00
commit 4e0219924d
83 changed files with 70924 additions and 0 deletions

106
src/main.cpp Normal file
View File

@@ -0,0 +1,106 @@
#include "App.hpp"
#include <GLFW/glfw3.h>
#include <RmlUi/Debugger/Debugger.h>
#include <iostream>
#include <RmlUi/Core/Context.h>
#include <RmlUi/Core/Core.h>
#include <RmlUi/Core/Math.h>
#include <RmlUi/Core.h>
#include <RmlUi_Backend.h>
#include <RmlUi/Debugger.h>
#include <RmlUi/Lua/Lua.h>
static bool is_initalized = false;
static bool is_running = false;
static Rml::Context *ctx;
static App *app;
bool InitalizeApplication() {
if (!Backend::Initialize("RmlUi App Template", 800, 600, true)) {
std::cout << "[ERROR] backend was not initalized successfully.\n";
return false;
}
Rml::SetSystemInterface(Backend::GetSystemInterface());
Rml::SetRenderInterface(Backend::GetRenderInterface());
Rml::Initialise();
Rml::Lua::Initialise();
ctx = Rml::CreateContext("main", Rml::Vector2i(800,600));
if (!ctx) {
std::cout << "[ERROR] context was null.\n";
Rml::Shutdown();
Backend::Shutdown();
return false;
}
Rml::Debugger::Initialise(ctx);
app = new App(ctx, nullptr);
if (!app) {
std::cout << "[ERROR] app was null.\n";
Rml::Shutdown();
Backend::Shutdown();
return false;
}
std::cout << "Application initalized...\n";
return true;
}
bool f5_was_pressed = false;
bool f8_was_pressed = false;
void handle_input() {
GLFWwindow *window = glfwGetCurrentContext();
if(window) {
// Reload main page
bool f5_state = glfwGetKey(window, GLFW_KEY_F5);
if (f5_state == GLFW_PRESS && !f5_was_pressed) {
f5_was_pressed = true;
app->Reload();
} else if (f5_state == GLFW_RELEASE) {
f5_was_pressed = false;
}
// Toggle debugger window
bool f8_state = glfwGetKey(window, GLFW_KEY_F8);
if (f8_state == GLFW_PRESS && !f8_was_pressed) {
f8_was_pressed = true;
bool is_visible = Rml::Debugger::IsVisible();
Rml::Debugger::SetVisible(!is_visible);
} else if (f8_state == GLFW_RELEASE) {
f8_was_pressed = false;
}
}
}
int main() {
std::cout << "Application starting...\n";
is_initalized = InitalizeApplication();
if (!is_initalized) return 1;
is_running = true;
std::cout << "Loading UI...\n";
app->LoadUi();
std::cout << "UI Loaded\n";
while (is_running) {
is_running = Backend::ProcessEvents(ctx);
handle_input();
ctx->Update();
Backend::BeginFrame();
ctx->Render();
Backend::PresentFrame();
}
delete app;
Rml::Shutdown();
Backend::Shutdown();
return 0;
}