From da9bddc70ff8544f3294b880d719c4605e87ad97 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Fri, 10 Jul 2026 15:17:41 -0400 Subject: Handle rotation from codec Signed-off-by: Andrew Opalach --- src/screen/view.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/screen/view.h') diff --git a/src/screen/view.h b/src/screen/view.h index 5fd86c0..ae6a357 100644 --- a/src/screen/view.h +++ b/src/screen/view.h @@ -40,7 +40,25 @@ struct camu_view { f64 fov; }; -void camu_view_init(struct camu_view *view, u32 width, u32 height); +static inline const char *camu_view_rotation_name(u8 rotation) +{ + switch (rotation) { + case CAMU_VIEW_ROTATION_0: return "0"; + case CAMU_VIEW_ROTATION_90: return "90"; + case CAMU_VIEW_ROTATION_180: return "180"; + case CAMU_VIEW_ROTATION_270: return "270"; + case CAMU_VIEW_ROTATION_360: return "360"; + } + al_assert_and_return(""); +} + +// This handles wrapping backwards for negative numbers. +static inline u8 camu_view_normalize_rotation(s32 rotation) +{ + return (u8)((rotation % CAMU_VIEW_ROTATION_360 + CAMU_VIEW_ROTATION_360) % CAMU_VIEW_ROTATION_360); +} + +void camu_view_init(struct camu_view *view, u32 width, u32 height, u8 rotation); void camu_view_calculate(struct camu_view *view, u32 window_width, u32 window_height); bool camu_view_zoom_simple(struct camu_view *view, u32 window_width, u32 window_height, f64 x, f64 y, f64 v); bool camu_view_pan_simple(struct camu_view *view, u32 window_width, u32 window_height, f64 dx, f64 dy); -- cgit v1.2.3-101-g0448