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;
33 struct time_state;
34 struct gui_scene_manager;
35 
36 
37 /*!
38  * A gui program.
39  *
40  * @ingroup gui
41  */
43 {
44  bool stopped;
45 
46  struct gui_scene_manager *gsm;
47 
48  struct time_state *timekeeping;
49  struct xrt_device *xdevs[NUM_XDEVS];
50  struct xrt_prober *xp;
51 
52  struct gui_ogl_texture *texs[256];
53  size_t num_texs;
54 };
55 
56 /*!
57  * A single currently running scene.
58  */
59 struct gui_scene
60 {
61  void (*render)(struct gui_scene *, struct gui_program *);
62  void (*destroy)(struct gui_scene *, struct gui_program *);
63 };
64 
65 /*!
66  * A OpenGL texture.
67  *
68  * @ingroup gui
69  */
71 {
72  uint64_t seq;
73  uint64_t dropped;
74  const char *name;
75  uint32_t w, h;
76  uint32_t id;
77  bool half;
78 
79  void *ptr;
80 };
81 
82 /*!
83  * Initialize the prober and open all devices found.
84  *
85  * @ingroup gui
86  */
87 int
88 gui_prober_init(struct gui_program *p);
89 
90 /*!
91  * Create devices.
92  *
93  * @ingroup gui
94  */
95 int
97 
98 /*!
99  * Update all devices.
100  *
101  * @ingroup gui
102  */
103 void
104 gui_prober_update(struct gui_program *p);
105 
106 /*!
107  * Destroy all opened devices and destroy the prober.
108  *
109  * @ingroup gui
110  */
111 void
113 
114 /*!
115  * Create a sink that will turn frames into OpenGL textures, since the frame
116  * can come from another thread @ref gui_ogl_sink_update needs to be called.
117  *
118  * Destruction is handled by the frame context.
119  *
120  * @ingroup gui
121  */
122 struct gui_ogl_texture *
123 gui_ogl_sink_create(const char *name,
124  struct xrt_frame_context *xfctx,
125  struct xrt_frame_sink **out_sink);
126 
127 /*!
128  * Update the texture to the latest received frame.
129  *
130  * @ingroup gui
131  */
132 void
134 
135 /*!
136  * Push the scene to the top of the lists.
137  *
138  * @ingroup gui
139  */
140 void
141 gui_scene_push_front(struct gui_program *p, struct gui_scene *me);
142 
143 /*!
144  * Put a scene on the delete list, also removes it from any other list.
145  *
146  * @ingroup gui
147  */
148 void
149 gui_scene_delete_me(struct gui_program *p, struct gui_scene *me);
150 
151 /*!
152  * Render the scenes.
153  *
154  * @ingroup gui
155  */
156 void
158 
159 /*!
160  * Initialize the scene manager.
161  *
162  * @ingroup gui
163  */
164 void
166 
167 /*!
168  * Destroy the scene manager.
169  *
170  * @ingroup gui
171  */
172 void
174 
175 
176 /*
177  *
178  * Scene creation functions.
179  *
180  */
181 
182 /*!
183  * Shows the main menu.
184  *
185  * @ingroup gui
186  */
187 void
189 
190 /*!
191  * Shows a UI that lets you select a video device and mode for calibration.
192  *
193  * @ingroup gui
194  */
195 void
197 
198 /*!
199  * Shows a UI that lets you select a video device and mode for testing.
200  *
201  * @ingroup gui
202  */
203 void
205 
206 /*!
207  * Regular debug UI.
208  *
209  * @ingroup gui
210  */
211 void
212 gui_scene_debug(struct gui_program *p);
213 
214 /*!
215  * Given the frameserver runs some debug code on it.
216  *
217  * @ingroup gui
218  */
219 void
221  struct xrt_frame_context *xfctx,
222  struct xrt_fs *xfs,
223  size_t mode);
224 
225 /*!
226  * Given the frameserver runs the calibration code on it.
227  *
228  * @ingroup gui
229  */
230 void
232  struct xrt_frame_context *xfctx,
233  struct xrt_fs *xfs,
234  size_t mode);
235 
236 
237 #ifdef __cplusplus
238 }
239 #endif
void gui_scene_debug_video(struct gui_program *p, struct xrt_frame_context *xfctx, struct xrt_fs *xfs, size_t mode)
Given the frameserver runs some debug code on it.
Definition: gui_scene_debug.c:372
void gui_scene_main_menu(struct gui_program *p)
Shows the main menu.
Definition: gui_scene_main_menu.c:72
void gui_scene_calibrate(struct gui_program *p, struct xrt_frame_context *xfctx, struct xrt_fs *xfs, size_t mode)
Given the frameserver runs the calibration code on it.
Definition: gui_scene_calibrate.c:320
Definition: gui_scene.cpp:16
void gui_scene_manager_render(struct gui_program *p)
Render the scenes.
Definition: gui_scene.cpp:64
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
A single currently running scene.
Definition: gui_common.h:59
The main prober that probes and manages found but not opened HMD devices that are connected to the sy...
Definition: xrt_prober.h:147
A gui program.
Definition: gui_common.h:42
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
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
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
void gui_scene_manager_init(struct gui_program *p)
Initialize the scene manager.
Definition: gui_scene.cpp:86
A OpenGL texture.
Definition: gui_common.h:70
Header holding common defines.
int gui_prober_init(struct gui_program *p)
Initialize the prober and open all devices found.
Definition: gui_prober.c:35
void gui_scene_select_video_test(struct gui_program *p)
Shows a UI that lets you select a video device and mode for testing.
Definition: gui_scene_video.c:147
void gui_scene_debug(struct gui_program *p)
Regular debug UI.
Definition: gui_scene_debug.c:413
A single HMD or input device.
Definition: xrt_device.h:203
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:159
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