monado/src/xrt/targets/gui/gui_common.h

163 lines
2.7 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 Common file for the Monado GUI program.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup gui
*/
#pragma once
2019-08-31 13:57:19 +00:00
#include "xrt/xrt_frame.h"
2019-07-21 14:45:50 +00:00
#include <SDL2/SDL.h>
/*!
* @defgroup gui GUI Config Interface
* @ingroup xrt
*
* @brief Small GUI interface to configure Monado based on SDL2.
*/
#ifdef __cplusplus
extern "C" {
#endif
2019-08-31 13:53:14 +00:00
#define NUM_XDEVS 8
struct xrt_device;
struct xrt_prober;
struct time_state;
2019-07-21 14:45:50 +00:00
/*!
* Common struct holding state for the GUI interface.
*
* @ingroup gui
*/
struct program
{
SDL_Window *win;
SDL_GLContext ctx;
bool stopped;
bool initialized;
struct
{
SDL_Surface *sf;
uint8_t *buffer;
size_t stride;
uint32_t width;
uint32_t height;
bool own_buffer;
} blit;
2019-08-31 13:53:14 +00:00
struct time_state *timekeeping;
struct xrt_device *xdevs[NUM_XDEVS];
struct xrt_prober *xp;
2019-08-31 13:57:19 +00:00
struct gui_ogl_texture *texs[256];
};
/*!
* A OpenGL texture.
*
* @ingroup gui
*/
struct gui_ogl_texture
{
uint64_t seq;
uint64_t dropped;
const char *name;
uint32_t w, h;
uint32_t id;
bool half;
2019-07-21 14:45:50 +00:00
};
/*!
* Init SDL2, create and show a window and bring up any other structs needed.
*
* @ingroup gui
*/
int
gui_sdl2_init(struct program *p);
/*!
* Loop until quit signal has been received.
*
* @ingroup gui
*/
void
gui_sdl2_loop(struct program *p);
/*!
* Display a 24bit RGB image on the screen.
*
* @ingroup gui
*/
void
gui_sdl2_display_R8G8B8(struct program *p,
bool resize,
uint32_t width,
uint32_t height,
size_t stride,
void *data);
/*!
* Destroy all SDL things and quit SDL.
*
* @ingroup gui
*/
void
gui_sdl2_quit(struct program *p);
2019-08-31 13:53:14 +00:00
/*!
* Initialize the prober and open all devices found.
*
* @ingroup gui
*/
int
gui_prober_init(struct program *p);
/*!
* Update all devices.
*
* @ingroup gui
*/
void
gui_prober_update(struct program *p);
/*!
* Destroy all opened devices and destroy the prober.
*
* @ingroup gui
*/
void
gui_prober_teardown(struct program *p);
2019-08-31 13:57:19 +00:00
/*!
* Create a sink that will turn frames into OpenGL textures, since the frame
* can come from another thread @ref gui_ogl_sink_update needs to be called.
*
* Destruction is handled by the frame context.
*
* @ingroup gui
*/
struct gui_ogl_texture *
gui_ogl_sink_create(const char *name,
struct xrt_frame_context *xfctx,
struct xrt_frame_sink **out_sink);
/*!
* Update the texture to the latest received frame.
*
* @ingroup gui
*/
void
gui_ogl_sink_update(struct gui_ogl_texture *);
2019-07-21 14:45:50 +00:00
#ifdef __cplusplus
}
#endif