diff options
Diffstat (limited to 'src/screen/view.h')
| -rw-r--r-- | src/screen/view.h | 20 |
1 files changed, 19 insertions, 1 deletions
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); |