diff options
| author | 2026-07-10 15:17:41 -0400 | |
|---|---|---|
| committer | 2026-07-10 15:17:41 -0400 | |
| commit | da9bddc70ff8544f3294b880d719c4605e87ad97 (patch) | |
| tree | 578f1554d992840aad4618ad0ce657868fcadc16 /src/screen/view.h | |
| parent | 566c022572bbff8bb7ff105b9adbe74500b2c716 (diff) | |
| download | camu-da9bddc70ff8544f3294b880d719c4605e87ad97.tar.gz camu-da9bddc70ff8544f3294b880d719c4605e87ad97.tar.bz2 camu-da9bddc70ff8544f3294b880d719c4605e87ad97.zip | |
Signed-off-by: Andrew Opalach <andrew@akon.city>
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); |