simvx.graphics.presentation¶
Where on the swapchain the scene’s space is drawn.
SceneTree.content_scale_mode decides the space the scene is laid out in.
Under EXPAND that space is the window, so the scene is drawn across the
whole swapchain and this module is the identity. Under FIT the scene is
laid out at a design resolution and presented scaled uniformly and centred,
with letterbox or pillarbox bars in the margin, and the renderer has to be told
the sub-rect to draw into and the size of the space it is drawing.
The rect comes from :attr:SceneTree.presentation_rect, which is the inverse of
the conversion the input router applies to every incoming pointer, so a control
is hit where it is drawn by construction rather than by two placements agreeing.
What this module adds is the conversion to physical pixels: the tree measures
the glass in engine units and the swapchain is a pixel grid, and the ratio
between them is taken from the extent rather than from the window’s reported
content scale so the rect can never fall outside the framebuffer.
Module Contents¶
Classes¶
The swapchain sub-rect the scene is presented into, and its own size. |
Functions¶
Where |
Data¶
API¶
- simvx.graphics.presentation.__all__¶
[‘Presentation’, ‘presentation_for’]
- class simvx.graphics.presentation.Presentation(rect: tuple[int, int, int, int], ui_size: tuple[float, float], letterboxed: bool)¶
The swapchain sub-rect the scene is presented into, and its own size.
rectis(x, y, width, height)in physical swapchain pixels;ui_sizeis the size of the space the scene laid itself out in, in engine units, which is what the 2D lanes divide vertex positions by.letterboxedis False whenever the rect is the whole swapchain, which is everyEXPANDframe and aFITframe whose window happens to match the design aspect: the draw sites read it to stay on their original path.Initialization
- __slots__¶
(‘rect’, ‘ui_size’, ‘letterboxed’)
- __repr__() str¶
- simvx.graphics.presentation.presentation_for(tree: Any, extent: tuple[int, int] | None) simvx.graphics.presentation.Presentation | None¶
Where
treeis presented on a swapchain ofextentphysical pixels.The whole extent under
EXPAND. UnderFITthe design rect placed by- Attr:
SceneTree.presentation_rect, converted to pixels by the extent over the glass and clamped inside it so a rounding step can never hand Vulkan a viewport that leaves the framebuffer.
Nonewhen there is no swapchain yet (Engine.extentbefore Vulkan is initialised), which every draw site already reads as “the whole target”.