t/sdl_test: Move system init earlier

This commit is contained in:
Jakob Bornecrantz 2023-12-12 21:29:02 +00:00
parent 7dd45db8ea
commit 6f60116fa9
3 changed files with 23 additions and 6 deletions

View file

@ -80,13 +80,9 @@ sdl_instance_create_system(struct xrt_instance *xinst,
assert(*out_xso == NULL);
assert(out_xsysc == NULL || *out_xsysc == NULL);
// Use system helper.
struct u_system *usys = u_system_create();
assert(usys != NULL); // Should never fail.
struct sdl_program *sp = from_xinst(xinst);
*out_xsys = &usys->base;
*out_xsys = &sp->usys->base;
*out_xsysd = &sp->xsysd_base;
*out_xso = sp->xso;
@ -99,7 +95,7 @@ sdl_instance_create_system(struct xrt_instance *xinst,
sdl_compositor_create_system(sp, &xsysc);
// Tell the system about the system compositor.
u_system_set_system_compositor(usys, xsysc);
u_system_set_system_compositor(sp->usys, xsysc);
*out_xsysc = xsysc;
@ -122,6 +118,15 @@ sdl_instance_destroy(struct xrt_instance *xinst)
*
*/
void
sdl_system_init(struct sdl_program *sp)
{
struct u_system *usys = u_system_create();
assert(usys != NULL); // Should never fail.
sp->usys = usys;
}
void
sdl_system_devices_init(struct sdl_program *sp)
{

View file

@ -119,6 +119,9 @@ struct sdl_program
//! Instance base.
struct xrt_instance xinst_base;
//! System, implemented for now using helper code.
struct u_system *usys;
//! System devices base.
struct xrt_system_devices xsysd_base;
@ -352,6 +355,14 @@ sdl_compositor_create_system(struct sdl_program *sp, struct xrt_system_composito
*
*/
/*!
* Init the @ref xrt_system (and @ref u_system) struct.
*
* @ingroup sdl_test
*/
void
sdl_system_init(struct sdl_program *sp);
/*!
* Init the @ref xrt_system_devices sub struct.
*

View file

@ -90,6 +90,7 @@ sdl_program_plus_create()
// Init sub components.
sdl_instance_init(&spp);
sdl_system_init(&spp);
sdl_device_init(&spp);
sdl_system_devices_init(&spp);
sdl_compositor_init(&spp); // Needs the window.