/* * 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 Rml::Context* context = nullptr; 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; ShellRenderInterfaceOpenGL opengl_renderer; shell_renderer = &opengl_renderer; // Generic OS initialisation, creates a window and attaches OpenGL. if (!Shell::Initialise() || !Shell::OpenWindow("Template Tutorial", shell_renderer, window_width, window_height, true)) { Shell::Shutdown(); return -1; } // RmlUi initialisation. Rml::SetRenderInterface(&opengl_renderer); opengl_renderer.SetViewport(window_width, window_height); ShellSystemInterface system_interface; Rml::SetSystemInterface(&system_interface); Rml::Initialise(); // Create the main RmlUi context and set it on the shell's input layer. context = Rml::CreateContext("main", Rml::Vector2i(window_width, window_height)); if (context == nullptr) { Rml::Shutdown(); Shell::Shutdown(); return -1; } Rml::Debugger::Initialise(context); Input::SetContext(context); Shell::SetContext(context); Shell::LoadFonts("assets/"); // Load and show the tutorial document. if (Rml::ElementDocument * document = context->LoadDocument("tutorial/template/data/tutorial.rml")) document->Show(); Shell::EventLoop(GameLoop); // Shutdown RmlUi. Rml::Shutdown(); Shell::CloseWindow(); Shell::Shutdown(); return 0; }