Monado OpenXR Runtime
gui_common.h
Go to the documentation of this file.
1 // Copyright 2019, 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 #define NUM_XDEVS 8
27 
28 struct xrt_device;
29 struct xrt_prober;
30 struct xrt_fs;
31 struct xrt_frame_sink;
32 struct xrt_frame_context;
34 struct time_state;
35 struct gui_scene_manager;
36 
37 
38 /*!
39  * A gui program.
40  *
41  * @ingroup gui
42  */
44 {
45  bool stopped;
46 
48 
51  struct xrt_prober *xp;
52 
53  struct gui_ogl_texture *texs[256];
54  size_t num_texs;
55 };
56 
57 /*!
58  * A single currently running scene.
59  */
60 struct gui_scene
61 {
62  void (*render)(struct gui_scene *, struct gui_program *);
63  void (*destroy)(struct gui_scene *, struct gui_program *);
64 };
65 
66 /*!
67  * A OpenGL texture.
68  *
69  * @ingroup gui
70  */
72 {
73  uint64_t seq;
74  uint64_t dropped;
75  const char *name;
76  uint32_t w, h;
77  uint32_t id;
78  bool half;
79 
80  void *ptr;
81 };
82 
83 /*!
84  * Initialize the prober and open all devices found.
85  *
86  * @ingroup gui
87  */
88 int
89 gui_prober_init(struct gui_program *p);
90 
91 /*!
92  * Create devices.
93  *
94  * @ingroup gui
95  */
96 int
98 
99 /*!
100  * Update all devices.
101  *
102  * @ingroup gui
103  */
104 void
105 gui_prober_update(struct gui_program *p);
106 
107 /*!
108  * Destroy all opened devices and destroy the prober.
109  *
110  * @ingroup gui
111  */
112 void
114 
115 /*!
116  * Create a sink that will turn frames into OpenGL textures, since the frame
117  * can come from another thread @ref gui_ogl_sink_update needs to be called.
118  *
119  * Destruction is handled by the frame context.
120  *
121  * @ingroup gui
122  */
123 struct gui_ogl_texture *
124 gui_ogl_sink_create(const char *name,
125  struct xrt_frame_context *xfctx,
126  struct xrt_frame_sink **out_sink);
127 
128 /*!
129  * Update the texture to the latest received frame.
130  *
131  * @ingroup gui
132  */
133 void
135 
136 /*!
137  * Push the scene to the top of the lists.
138  *
139  * @ingroup gui
140  */
141 void
142 gui_scene_push_front(struct gui_program *p, struct gui_scene *me);
143 
144 /*!
145  * Put a scene on the delete list, also removes it from any other list.
146  *
147  * @ingroup gui
148  */
149 void
150 gui_scene_delete_me(struct gui_program *p, struct gui_scene *me);
151 
152 /*!
153  * Render the scenes.
154  *
155  * @ingroup gui
156  */
157 void
159 
160 /*!
161  * Initialize the scene manager.
162  *
163  * @ingroup gui
164  */
165 void
167 
168 /*!
169  * Destroy the scene manager.
170  *
171  * @ingroup gui
172  */
173 void
175 
176 
177 /*
178  *
179  * Scene creation functions.
180  *
181  */
182 
183 /*!
184  * Shows the main menu.
185  *
186  * @ingroup gui
187  */
188 void
190 
191 /*!
192  * Shows a UI that lets you select a video device and mode for calibration.
193  *
194  * @ingroup gui
195  */
196 void
198 
199 /*!
200  * Regular debug UI.
201  *
202  * @ingroup gui
203  */
204 void
205 gui_scene_debug(struct gui_program *p);
206 
207 /*!
208  * Given the frameserver runs the calibration code on it.
209  * Claims ownership of @p s.
210  *
211  * @ingroup gui
212  */
213 void
215  struct xrt_frame_context *xfctx,
216  struct xrt_fs *xfs,
217  struct xrt_settings_tracking *s);
218 
219 
220 #ifdef __cplusplus
221 }
222 #endif
void gui_scene_main_menu(struct gui_program *p)
Shows the main menu.
Definition: gui_scene_main_menu.c:67
Definition: gui_scene.cpp:16
void gui_scene_manager_render(struct gui_program *p)
Render the scenes.
Definition: gui_scene.cpp:64
bool half
Definition: gui_common.h:78
struct time_state * timekeeping
Definition: gui_common.h:49
void * ptr
Definition: gui_common.h:80
A object that is sent frames.
Definition: xrt_frame.h:51
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.c:138
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
#define NUM_XDEVS
Definition: gui_common.h:26
struct xrt_device * xdevs[NUM_XDEVS]
Definition: gui_common.h:50
uint64_t dropped
Definition: gui_common.h:74
A single currently running scene.
Definition: gui_common.h:60
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:153
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:409
A gui program.
Definition: gui_common.h:43
void gui_prober_update(struct gui_program *p)
Update all devices.
Definition: gui_prober.c:71
Time-keeping state structure.
Definition: u_time.cpp:46
uint32_t id
Definition: gui_common.h:77
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
uint32_t w
Definition: gui_common.h:76
Object used to track all sinks and frame producers in a graph.
Definition: xrt_frame.h:87
void gui_ogl_sink_update(struct gui_ogl_texture *)
Update the texture to the latest received frame.
Definition: gui_ogl.c:94
int gui_prober_select(struct gui_program *p)
Create devices.
Definition: gui_prober.c:57
size_t num_texs
Definition: gui_common.h:54
bool stopped
Definition: gui_common.h:45
void gui_scene_manager_init(struct gui_program *p)
Initialize the scene manager.
Definition: gui_scene.cpp:86
Holding enough information to recreate a tracking pipeline.
Definition: xrt_settings.h:42
A OpenGL texture.
Definition: gui_common.h:71
Header holding common defines.
const char * name
Definition: gui_common.h:75
struct xrt_prober * xp
Definition: gui_common.h:51
int gui_prober_init(struct gui_program *p)
Initialize the prober and open all devices found.
Definition: gui_prober.c:35
void gui_scene_debug(struct gui_program *p)
Regular debug UI.
Definition: gui_scene_debug.c:373
uint64_t seq
Definition: gui_common.h:73
A single HMD or input device.
Definition: xrt_device.h:202
void gui_scene_manager_destroy(struct gui_program *p)
Destroy the scene manager.
Definition: gui_scene.cpp:92
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:171
struct gui_ogl_texture * texs[256]
Definition: gui_common.h:53
void gui_prober_teardown(struct gui_program *p)
Destroy all opened devices and destroy the prober.
Definition: gui_prober.c:90
Frameserver that generates frame, multiple subframes (like stereo and mipmaps) can be generate in one...
Definition: xrt_frameserver.h:51
struct gui_scene_manager * gsm
Definition: gui_common.h:47