This sample demonstrates a Vulkan-based image viewer with zoom and pan functionality, and dynamic texture sampler adjustment.
- Image loading and display
- Zoom functionality (mouse wheel)
- Pan functionality (mouse drag)
- Texture sampler switching (nearest/linear)
- Implemented in
onUIRender()
- Mouse-over viewport detection
- Zoom level adjustment via mouse wheel
- Pan offset calculation accounting for zoom level
- Values pushed to shader in
onRender()
via orthographic matrix
- Image rendered on a square primitive
- Aspect ratio preservation:
- Scaling applied in
onRender()
- Maintains image proportions relative to viewport dimensions
- Scaling applied in
- Orthographic matrix in vertex shader:
- Incorporates zoom (scale) and pan (translation)
- Dynamic switching between nearest and linear sampling
- Efficient viewport mouse position tracking
- Optimized zoom and pan calculations for smooth user experience