| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- /*
- * This source file is part of RmlUi, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://github.com/mikke89/RmlUi
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- * Copyright (c) 2019 The RmlUi Team, and contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
- #ifndef RMLUI_BACKENDS_BACKEND_H
- #define RMLUI_BACKENDS_BACKEND_H
- #include <RmlUi/Core/Input.h>
- #include <RmlUi/Core/RenderInterface.h>
- #include <RmlUi/Core/SystemInterface.h>
- #include <RmlUi/Core/Types.h>
- using KeyDownCallback = bool (*)(Rml::Context* context, Rml::Input::KeyIdentifier key, int key_modifier, float native_dp_ratio, bool priority);
- /**
- This interface serves as a basic abstraction over the various backends included with RmlUi. It is mainly intended as an example to get something
- simple up and running, and provides just enough functionality for the included samples.
- This interface may be used directly for simple applications and testing. However, for anything more advanced we recommend to use the backend as a
- starting point and copy relevant parts into the main loop of your application. On the other hand, the underlying platform and renderer used by the
- backend are intended to be re-usable as is.
- */
- namespace Backend {
- // Initializes the backend, including the custom system and render interfaces, and opens a window for rendering the RmlUi context.
- bool Initialize(const char* window_name, int width, int height, bool allow_resize);
- // Closes the window and release all resources owned by the backend, including the system and render interfaces.
- void Shutdown();
- // Returns a pointer to the custom system interface which should be provided to RmlUi.
- Rml::SystemInterface* GetSystemInterface();
- // Returns a pointer to the custom render interface which should be provided to RmlUi.
- Rml::RenderInterface* GetRenderInterface();
- // Polls and processes events from the current platform, and applies any relevant events to the provided RmlUi context and the key down callback.
- // @return False to indicate that the application should be closed.
- bool ProcessEvents(Rml::Context* context, KeyDownCallback key_down_callback = nullptr);
- // Request application closure during the next event processing call.
- void RequestExit();
- // Prepares the render state to accept rendering commands from RmlUi, call before rendering the RmlUi context.
- void BeginFrame();
- // Presents the rendered frame to the screen, call after rendering the RmlUi context.
- void PresentFrame();
- } // namespace Backend
- #endif
|