22 const float hw = st.
zoom * aspect;
23 const float hh = st.
zoom;
25 .view = glm::mat4(1.0F),
26 .projection = glm::ortho(
27 st.
pan.x - hw, st.
pan.x + hw,
28 st.
pan.y - hh, st.
pan.y + hh,
34 float viewport_width,
float viewport_height)
36 const float aspect = viewport_width / viewport_height;
39 { 2.0F * st.
zoom * aspect, 2.0F * st.
zoom },
40 { viewport_width, viewport_height });
ViewTransform compute_pan_zoom_view_transform(const PanZoom2DState &st, float aspect)
Build a ViewTransform from the current PanZoom2DState.
PanZoom2DState make_pan_zoom_state(const PanZoom2DConfig &config)
Construct a PanZoom2DState from a PanZoom2DConfig.
void apply_pan_zoom_scroll(PanZoom2DState &st, float ticks)
Zoom by multiplying the half-height, clamped to [min_zoom, max_zoom].
void apply_pan_zoom_pan(PanZoom2DState &st, float dx, float dy, float viewport_width, float viewport_height)
Pan by a pixel delta, scaled to world units by the current zoom level.
glm::vec2 drag_to_offset_delta(glm::vec2 pixel_delta, glm::vec2 visible_extent, glm::vec2 viewport_size_pixels) noexcept
Convert a pixel-space drag delta into a content-space delta.
float max_zoom
Maximum half-height (maximum zoom out)
glm::vec2 initial_pan
Initial pan offset in world units.
float initial_zoom
Initial half-height of the orthographic frustum.
float scroll_speed
Fractional zoom change per scroll tick.
float min_zoom
Minimum half-height (maximum zoom in)
Construction parameters for a 2D pan/zoom orthographic controller.
float zoom
Orthographic half-height.
glm::vec2 pan
World-space pan offset.
Mutable 2D pan/zoom navigation state.