Inital project
This commit is contained in:
83
src/main.cpp
Normal file
83
src/main.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
#include <RmlUi/Core/Core.h>
|
||||
#include <RmlUi/Core/ElementDocument.h>
|
||||
#include <RmlUi/Core/Math.h>
|
||||
#include <RmlUi/Lua/Interpreter.h>
|
||||
#include <RmlUi/Lua/Lua.h>
|
||||
#include <iostream>
|
||||
#include <RmlUi/Core.h>
|
||||
#include <RmlUi_Backend.h>
|
||||
#include <RmlUi/Lua/Lua.h>
|
||||
#include <RmlUi/Core/Context.h>
|
||||
#include <lua.h>
|
||||
#include <RmlUi/Debugger/Debugger.h>
|
||||
|
||||
|
||||
|
||||
static bool is_initalized = false;
|
||||
static bool is_running = false;
|
||||
static Rml::Context *ctx;
|
||||
|
||||
void Shutdown() {
|
||||
Rml::Shutdown();
|
||||
Backend::Shutdown();
|
||||
}
|
||||
|
||||
bool Initalize() {
|
||||
if (!Backend::Initialize("CritterFolio", 800, 600, true)) {
|
||||
std::cout << "[ERROR] Failed to initalize the backend.";
|
||||
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] Failed to create context.";
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
Rml::Debugger::Initialise(ctx);
|
||||
|
||||
// lua_State *L = Rml::Lua::Interpreter::GetLuaState();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello world!\n";
|
||||
|
||||
is_initalized = Initalize();
|
||||
if (!is_initalized) {
|
||||
std::cout << "[ERROR] Failed to initalize, shutting down.";
|
||||
Shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
is_running = true;
|
||||
|
||||
Rml::ElementDocument *doc;
|
||||
doc = ctx->LoadDocument("./assets/main.rml");
|
||||
if (!doc) {
|
||||
std::cout << "[ERROR] Could no load assets/main.rml document, shutting down.";
|
||||
Shutdown();
|
||||
return 1;
|
||||
}
|
||||
|
||||
doc->Show();
|
||||
|
||||
while(is_running) {
|
||||
is_running = Backend::ProcessEvents(ctx);
|
||||
|
||||
ctx->Update();
|
||||
Backend::BeginFrame();
|
||||
ctx->Render();
|
||||
Backend::PresentFrame();
|
||||
}
|
||||
|
||||
Shutdown();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user