| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /*
- * 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 [email protected].
- *
- */
- #include <RmlUi/Core.h>
- #include <RmlUi/Debugger.h>
- #include <Input.h>
- #include <Shell.h>
- #include <ShellRenderInterfaceOpenGL.h>
- #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 <windows.h>
- 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<ShellRenderInterfaceOpenGL>();
- 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<ShellSystemInterface>());
- 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;
- }
|