Monado OpenXR Runtime
gui_common.h
Go to the documentation of this file.
1 // Copyright 2019-2023, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Common file for the Monado GUI program.
6  * @author Jakob Bornecrantz <jakob@collabora.com>
7  * @ingroup gui
8  */
9 
10 #pragma once
11 
12 #include "xrt/xrt_compiler.h"
13 
14 
15 /*!
16  * @defgroup gui GUI Config Interface
17  * @ingroup xrt
18  *
19  * @brief Small GUI interface to configure Monado based on SDL2.
20  */
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 
27 struct xrt_device;
28 struct xrt_prober;
29 struct xrt_fs;
30 struct xrt_frame_sink;
31 struct xrt_frame_context;
33 struct time_state;
34 struct gui_scene_manager;
35 struct xrt_system_devices;
36 
37 
38 /*!
39  * A gui program.
40  *
41  * @ingroup gui
42  */
44 {
45  bool stopped;
46 
47  struct gui_scene_manager *gsm;
48 
49  struct xrt_system *xsys;
50  struct xrt_system_devices *xsysd;
51  struct xrt_space_overseer *xso;
52  struct xrt_instance *instance;
53  struct xrt_prober *xp;
54 
55  struct gui_ogl_texture *texs[256];
56  size_t num_texs;
57 };
58 
59 /*!
60  * @interface gui_scene
61  * A single currently running scene.
62  *
63  * @ingroup gui
64  */
65 struct gui_scene
66 {
67  void (*render)(struct gui_scene *, struct gui_program *);
68  void (*destroy)(struct gui_scene *, struct gui_program *);
69 };
70 
71 /*!
72  * A OpenGL texture.
73  *
74  * @ingroup gui
75  */
77 {
78  uint64_t seq;
79  uint64_t dropped;
80  const char *name;
81  uint32_t w, h;
82  uint32_t id;
83  bool half;
84 };
85 
86 /*!
87  * Initialize the prober and open all devices found.
88  *
89  * @ingroup gui
90  */
91 int
92 gui_prober_init(struct gui_program *p);
93 
94 /*!
95  * Create devices.
96  *
97  * @ingroup gui
98  */
99 int
100 gui_prober_select(struct gui_program *p);
101 
102 /*!
103  * Update all devices.
104  *
105  * @ingroup gui
106  */
107 void
108 gui_prober_update(struct gui_program *p);
109 
110 /*!
111  * Destroy all opened devices and destroy the prober.
112  *
113  * @ingroup gui
114  */
115 void
117 
118 /*!
119  * Create a sink that will turn frames into OpenGL textures, since the frame
120  * can come from another thread @ref gui_ogl_sink_update needs to be called.
121  *
122  * Destruction is handled by the frame context.
123  *
124  * @ingroup gui
125  */
126 struct gui_ogl_texture *
127 gui_ogl_sink_create(const char *name, struct xrt_frame_context *xfctx, struct xrt_frame_sink **out_sink);
128 
129 /*!
130  * Update the texture to the latest received frame.
131  *
132  * @ingroup gui
133  */
134 void
135 gui_ogl_sink_update(struct gui_ogl_texture * /*tex*/);
136 
137 /*!
138  * Push the scene to the top of the lists.
139  *
140  * @ingroup gui
141  */
142 void
143 gui_scene_push_front(struct gui_program *p, struct gui_scene *me);
144 
145 /*!
146  * Put a scene on the delete list, also removes it from any other list.
147  *
148  * @ingroup gui
149  */
150 void
151 gui_scene_delete_me(struct gui_program *p, struct gui_scene *me);
152 
153 /*!
154  * Render the scenes.
155  *
156  * @ingroup gui
157  */
158 void
160 
161 /*!
162  * Initialize the scene manager.
163  *
164  * @ingroup gui
165  */
166 void
168 
169 /*!
170  * Destroy the scene manager.
171  *
172  * @ingroup gui
173  */
174 void
176 
177 
178 /*
179  *
180  * Scene creation functions.
181  *
182  */
183 
184 /*!
185  * Shows the main menu.
186  *
187  * @ingroup gui
188  */
189 void
191 
192 /*!
193  * Shows a UI that lets you select a video device and mode for calibration.
194  *
195  * @ingroup gui
196  */
197 void
199 
200 /*!
201  * Shows a UI that lets you set up tracking overrides.
202  *
203  * @ingroup gui
204  */
205 void
207 
208 /*!
209  * Regular debug UI.
210  *
211  * @ingroup gui
212  */
213 void
214 gui_scene_debug(struct gui_program *p);
215 
216 /*!
217  * Small hand-tracking demo.
218  *
219  * @ingroup gui
220  */
221 void
223 
224 /*!
225  * EuRoC recorder for DepthAI cameras
226  *
227  * @ingroup gui
228  */
229 void
231 
232 /*!
233  * Create a recording view scene.
234  *
235  * @ingroup gui
236  */
237 void
238 gui_scene_record(struct gui_program *p, const char *camera);
239 
240 /*!
241  * Remote control debugging UI.
242  *
243  * @param Optional address.
244  * @ingroup gui
245  */
246 void
247 gui_scene_remote(struct gui_program *p, const char *address);
248 
249 /*!
250  * Given the frameserver runs the calibration code on it.
251  * Claims ownership of @p s.
252  *
253  * @ingroup gui
254  */
255 void
257  struct xrt_frame_context *xfctx,
258  struct xrt_fs *xfs,
259  struct xrt_settings_tracking *s);
260 
261 
262 #ifdef __cplusplus
263 }
264 #endif
void gui_scene_delete_me(struct gui_program *p, struct gui_scene *me)
Put a scene on the delete list, also removes it from any other list.
Definition: gui_scene.cpp:45
void gui_prober_update(struct gui_program *p)
Update all devices.
Definition: gui_prober.c:84
void gui_scene_push_front(struct gui_program *p, struct gui_scene *me)
Push the scene to the top of the lists.
Definition: gui_scene.cpp:24
int gui_prober_init(struct gui_program *p)
Initialize the prober and open all devices found.
Definition: gui_prober.c:41
void gui_scene_main_menu(struct gui_program *p)
Shows the main menu.
Definition: gui_scene_main_menu.c:113
void gui_scene_record(struct gui_program *p, const char *camera)
Create a recording view scene.
Definition: gui_scene_record.c:414
void gui_ogl_sink_update(struct gui_ogl_texture *)
Update the texture to the latest received frame.
Definition: gui_ogl_sink.c:115
void gui_scene_manager_render(struct gui_program *p)
Render the scenes.
Definition: gui_scene.cpp:64
void gui_scene_select_video_calibrate(struct gui_program *p)
Shows a UI that lets you select a video device and mode for calibration.
Definition: gui_scene_video.c:258
void gui_scene_debug(struct gui_program *p)
Regular debug UI.
Definition: gui_scene_debug.c:1002
void gui_scene_hand_tracking_demo(struct gui_program *p)
Small hand-tracking demo.
Definition: gui_scene_hand_tracking_demo.c:116
void gui_scene_remote(struct gui_program *p, const char *address)
Remote control debugging UI.
Definition: gui_scene_remote.c:448
int gui_prober_select(struct gui_program *p)
Create devices.
Definition: gui_prober.c:71
void gui_scene_tracking_overrides(struct gui_program *p)
Shows a UI that lets you set up tracking overrides.
Definition: gui_scene_tracking_overrides.c:355
void gui_prober_teardown(struct gui_program *p)
Destroy all opened devices and destroy the prober.
Definition: gui_prober.c:101
void gui_scene_manager_init(struct gui_program *p)
Initialize the scene manager.
Definition: gui_scene.cpp:86
struct gui_ogl_texture * gui_ogl_sink_create(const char *name, struct xrt_frame_context *xfctx, struct xrt_frame_sink **out_sink)
Create a sink that will turn frames into OpenGL textures, since the frame can come from another threa...
Definition: gui_ogl_sink.c:178
void gui_scene_manager_destroy(struct gui_program *p)
Destroy the scene manager.
Definition: gui_scene.cpp:92
void gui_scene_calibrate(struct gui_program *p, struct xrt_frame_context *xfctx, struct xrt_fs *xfs, struct xrt_settings_tracking *s)
Given the frameserver runs the calibration code on it.
Definition: gui_scene_calibrate.c:399
void gui_scene_record_euroc(struct gui_program *p)
EuRoC recorder for DepthAI cameras.
Definition: gui_scene_record_euroc.c:99
A OpenGL texture.
Definition: gui_common.h:77
A gui program.
Definition: gui_common.h:44
Definition: gui_scene.cpp:17
A single currently running scene.
Definition: gui_common.h:66
Time-keeping state structure.
Definition: u_time.cpp:30
A single HMD or input device.
Definition: xrt_device.h:230
Object used to track all sinks and frame producers in a graph.
Definition: xrt_frame.h:108
A object that is sent frames.
Definition: xrt_frame.h:58
Frameserver that generates frames.
Definition: xrt_frameserver.h:70
This interface acts as a root object for Monado.
Definition: xrt_instance.h:67
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:132
Holding enough information to recreate a tracking pipeline.
Definition: xrt_settings.h:67
Object that oversees and manages spaces, one created for each XR system.
Definition: xrt_space.h:95
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition: xrt_system.h:218
A system is a collection of devices, policies and optionally a compositor that is organised into a ch...
Definition: xrt_system.h:61
Header holding common defines.