Skip to content
Snippets Groups Projects

demos/plplay: Keybinds to toggle UI and fullscreen

Open Srijan Dhungana requested to merge Sirtsu55/libplacebo:master into master
Files
6
+ 24
3
@@ -370,13 +370,31 @@ static void update_colorspace_hint(struct plplay *p, const struct pl_frame_mix *
pl_swapchain_colorspace_hint(p->win->swapchain, &hint);
}
static bool process_key_events(struct plplay *p)
{
if (window_get_key(p->win, KEY_ESC))
return false;
if (window_get_key_pressed(p->win, KEY_F)) {
p->toggle_fullscreen = true;
}
if (window_get_key_pressed(p->win, KEY_H)) {
p->hide_ui = !p->hide_ui;
}
return true;
}
static bool render_frame(struct plplay *p, const struct pl_swapchain_frame *frame,
const struct pl_frame_mix *mix)
{
struct pl_frame target;
pl_options opts = p->opts;
pl_frame_from_swapchain(&target, frame);
update_settings(p, &target);
if (!p->hide_ui)
update_settings(p, &target);
if (p->target_override) {
target.repr = p->force_repr;
@@ -512,11 +530,14 @@ static bool render_loop(struct plplay *p)
double pts_target = 0.0, prev_pts = 0.0;
while (!p->win->window_lost) {
if (window_get_key(p->win, KEY_ESC))
if (!process_key_events(p))
break;
if (p->toggle_fullscreen)
if (p->toggle_fullscreen) {
window_toggle_fullscreen(p->win, !window_is_fullscreen(p->win));
p->toggle_fullscreen = false;
}
update_colorspace_hint(p, &mix);
pl_clock_t ts_acquire = pl_clock_now();
Loading