/* * Copyright (c) 2006 - 2008 * Wandering Monster Studios Limited * * Any use of this program is governed by the terms of Wandering Monster * Studios Limited's Licence Agreement included with this program, a copy * of which can be obtained by contacting Wandering Monster Studios * Limited at info@wanderingmonster.co.nz. * */ #include #include #include #include #include #include "Inventory.h" Rml::Core::Context* context = NULL; ShellRenderInterfaceExtensions *shell_renderer; void GameLoop() { context->Update(); shell_renderer->PrepareRenderBuffer(); context->Render(); shell_renderer->PresentRenderBuffer(); } #if defined RMLUI_PLATFORM_WIN32 #include int APIENTRY WinMain(HINSTANCE RMLUI_UNUSED_PARAMETER(instance_handle), HINSTANCE RMLUI_UNUSED_PARAMETER(previous_instance_handle), char* RMLUI_UNUSED_PARAMETER(command_line), int RMLUI_UNUSED_PARAMETER(command_show)) #else int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv)) #endif { #ifdef RMLUI_PLATFORM_WIN32 RMLUI_UNUSED(instance_handle); RMLUI_UNUSED(previous_instance_handle); RMLUI_UNUSED(command_line); RMLUI_UNUSED(command_show); #else RMLUI_UNUSED(argc); RMLUI_UNUSED(argv); #endif #ifdef RMLUI_PLATFORM_WIN32 AllocConsole(); #endif int window_width = 1024; int window_height = 768; auto opengl_renderer = std::make_shared(); shell_renderer = opengl_renderer.get(); // Generic OS initialisation, creates a window and attaches OpenGL. if (!Shell::Initialise() || !Shell::OpenWindow("Drag Tutorial", shell_renderer, window_width, window_height, true)) { Shell::Shutdown(); return -1; } // RmlUi initialisation. Rml::Core::SetRenderInterface(opengl_renderer); opengl_renderer->SetViewport(window_width, window_height); Rml::Core::SetSystemInterface(std::make_shared()); Rml::Core::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. context = Rml::Core::CreateContext("main", Rml::Core::Vector2i(window_width, window_height)); if (context == NULL) { Rml::Core::Shutdown(); Shell::Shutdown(); return -1; } Rml::Debugger::Initialise(context); Input::SetContext(context); shell_renderer->SetContext(context); Shell::LoadFonts("assets/"); // Load and show the inventory document. Inventory* inventory_1 = new Inventory("Inventory 1", Rml::Core::Vector2f(50, 200), context); Inventory* inventory_2 = new Inventory("Inventory 2", Rml::Core::Vector2f(540, 240), context); // Add items into the inventory. inventory_1->AddItem("Mk III L.A.S.E.R."); inventory_1->AddItem("Gravity Descender"); inventory_1->AddItem("Closed-Loop Ion Beam"); inventory_1->AddItem("5kT Mega-Bomb"); Shell::EventLoop(GameLoop); delete inventory_1; delete inventory_2; // Shutdown RmlUi. Rml::Core::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); return 0; }