The open source OpenXR runtime
at main 91 lines 2.2 kB view raw
1// Copyright 2019-2023, Collabora, Ltd. 2// Copyright 2024-2025, NVIDIA CORPORATION. 3// SPDX-License-Identifier: BSL-1.0 4/*! 5 * @file 6 * @brief SDL2 Debug UI implementation 7 * @author Jakob Bornecrantz <jakob@collabora.com> 8 * @author Moshi Turner <moshiturner@protonmail.com> 9 */ 10 11#pragma once 12 13#include "xrt/xrt_compiler.h" 14 15 16#ifdef __cplusplus 17extern "C" { 18#endif 19 20#define U_DEBUG_GUI_WINDOW_TITLE_MAX (256) 21 22struct xrt_instance; 23struct xrt_system_devices; 24 25struct u_debug_gui; 26 27/*! 28 * Controls if the debug gui window is opened, allowing code to always call 29 * create and progmatically or external control if the window is opened. 30 * 31 * @ingroup aux_util 32 */ 33enum u_debug_gui_open 34{ 35 //! Opens the window if the environmental variable XRT_DEBUG_GUI is true. 36 U_DEBUG_GUI_OPEN_AUTO, 37 //! Always (if supported) opens the window. 38 U_DEBUG_GUI_OPEN_ALWAYS, 39 //! Never opens the window. 40 U_DEBUG_GUI_OPEN_NEVER, 41}; 42 43/*! 44 * Argument to the function @ref u_debug_gui_create. 45 * 46 * @ingroup aux_util 47 */ 48struct u_debug_gui_create_info 49{ 50 char window_title[U_DEBUG_GUI_WINDOW_TITLE_MAX]; 51 52 enum u_debug_gui_open open; 53}; 54 55/*! 56 * Creates the debug gui, may not create it. 57 * 58 * If the debug gui is disabled through the means listed below this function 59 * will return 0, but not create any struct and set @p out_debug_gui to NULL. 60 * It is safe to call the other functions with a NULL @p debug_gui argument. 61 * 62 * The window will be disabled and 0 returned if: 63 * * Monado was compiled without the needed dependencies, like SDL. 64 * * The @p open field on the info struct set to NEVER. 65 * * The XRT_DEBUG_GUI env variable is false (or unset). 66 * 67 * @ingroup aux_util 68 */ 69int 70u_debug_gui_create(const struct u_debug_gui_create_info *info, struct u_debug_gui **out_debug_gui); 71 72/*! 73 * Starts the debug gui, also passes in some structs that might be needed. 74 * 75 * @ingroup aux_util 76 */ 77void 78u_debug_gui_start(struct u_debug_gui *debug_gui, struct xrt_instance *xinst, struct xrt_system_devices *xsysd); 79 80/*! 81 * Stops the debug gui, closing the window and freeing resources. 82 * 83 * @ingroup aux_util 84 */ 85void 86u_debug_gui_stop(struct u_debug_gui **debug_gui); 87 88 89#ifdef __cplusplus 90} 91#endif