#pragma once #include enum { CAMU_VIEW_NONE = 0, CAMU_VIEW_AUTOFIT, CAMU_VIEW_ZOOM, CAMU_VIEW_DETACHED }; enum { CAMU_VIEW_ROTATION_0 = 0, CAMU_VIEW_ROTATION_90, CAMU_VIEW_ROTATION_180, CAMU_VIEW_ROTATION_270, CAMU_VIEW_ROTATION_360 }; enum { CAMU_VR_DISABLED = 0, CAMU_VR_180, CAMU_VR_360 }; #define CAMU_DEFAULT_VIEW CAMU_VIEW_AUTOFIT #define CAMU_DEFAULT_FOV 80.0 struct camu_view { u8 mode; u8 rotation; u32 width; u32 height; s32 zindex; f64 zoom; f64 x_offset; f64 y_offset; f64 stretch; f64 fov; }; 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); bool camu_view_zoom_fov(struct camu_view *view, f64 v);