monado/src/xrt/targets/gui/gui_sdl2_main.c

58 lines
1.1 KiB
C
Raw Normal View History

2019-07-21 14:45:50 +00:00
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Main entrypoint for the Monado GUI program.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup gui
*/
2019-09-02 12:20:09 +00:00
#include "util/u_var.h"
2019-10-09 15:22:34 +00:00
#include "gui_sdl2.h"
2019-07-21 14:45:50 +00:00
int
main(int argc, char **argv)
{
2019-10-09 15:22:34 +00:00
struct sdl2_program p = {0};
2019-07-21 14:45:50 +00:00
int ret;
2019-09-02 12:20:09 +00:00
// Need to do this as early as possible.
u_var_force_on();
2019-07-21 14:45:50 +00:00
ret = gui_sdl2_init(&p);
if (ret != 0) {
gui_sdl2_quit(&p);
return ret;
}
2019-09-02 12:20:09 +00:00
// To manage the scenes.
2019-10-09 15:22:34 +00:00
gui_scene_manager_init(&p.base);
2019-09-02 12:20:09 +00:00
// Start all of the devices.
2019-10-09 15:22:34 +00:00
gui_prober_init(&p.base);
2019-09-02 12:20:09 +00:00
// First scene to start with.
if (argc >= 2 && strcmp("debug", argv[1]) == 0) {
2019-10-09 15:22:34 +00:00
gui_scene_debug(&p.base);
2019-09-23 10:46:06 +00:00
} else if (argc >= 2 && strcmp("calibrate", argv[1]) == 0) {
2019-10-09 15:22:34 +00:00
gui_scene_select_video_calibrate(&p.base);
} else {
2019-10-09 15:22:34 +00:00
gui_scene_main_menu(&p.base);
}
2019-09-02 12:20:09 +00:00
// Main loop.
2019-10-09 15:22:34 +00:00
gui_sdl2_imgui_loop(&p);
2019-09-02 12:20:09 +00:00
// Clean up after us.
2019-10-09 15:22:34 +00:00
gui_prober_teardown(&p.base);
2019-09-02 12:20:09 +00:00
// All scenes should be destroyed by now.
2019-10-09 15:22:34 +00:00
gui_scene_manager_destroy(&p.base);
2019-07-21 14:45:50 +00:00
2019-09-02 12:20:09 +00:00
// Final close.
2019-07-21 14:45:50 +00:00
gui_sdl2_quit(&p);
return 0;
}