pub struct WgpuWindowPresenter { /* private fields */ }Expand description
Hardware wgpu window surface presenter managing 3D rendering + cached 2D HUD compositing.
Implementations§
Source§impl WgpuWindowPresenter
impl WgpuWindowPresenter
Sourcepub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
pub fn new_offscreen(present_mode: PresentMode) -> Result<Self, String>
Creates an offscreen-capable WgpuWindowPresenter with BGRA8 pixel format matching Cairo.
Sourcepub unsafe fn from_raw_handles(
window_handle: RawWindowHandle,
display_handle: RawDisplayHandle,
width: u32,
height: u32,
present_mode: PresentMode,
) -> Result<Self, String>
pub unsafe fn from_raw_handles( window_handle: RawWindowHandle, display_handle: RawDisplayHandle, width: u32, height: u32, present_mode: PresentMode, ) -> Result<Self, String>
Creates a WgpuWindowPresenter bound directly to a native window/display handle pair.
§Safety
window_handle and display_handle must remain valid for the lifetime of this presenter.
pub fn renderer_mut(&mut self) -> &mut Wgpu3DRenderer
pub fn active_wgpu_present_mode(&self) -> Option<PresentMode>
pub fn has_surface(&self) -> bool
pub fn resize(&mut self, width: u32, height: u32)
Sourcepub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
pub fn upload_ui_overlay_bgra(&mut self, width: u32, height: u32, bgra: &[u8])
Uploads a new cached 2D UI HUD overlay (BGRA8 pixels matching Cairo ARgb32).
Called only when 2D layout/DOM paint_dirty repaints; unchanged camera-only 3D frames
reuse this GPU texture with zero CPU work.
Sourcepub fn upload_ui_overlay_bgra_rects(
&mut self,
width: u32,
height: u32,
stride: usize,
bgra: &[u8],
rects: &[(u32, u32, u32, u32)],
scratch: &mut Vec<u8>,
)
pub fn upload_ui_overlay_bgra_rects( &mut self, width: u32, height: u32, stride: usize, bgra: &[u8], rects: &[(u32, u32, u32, u32)], scratch: &mut Vec<u8>, )
Uploads only damaged sub-rectangles of the 2D UI HUD overlay texture, avoiding full-frame 8 MB CPU-to-GPU transfers when only small labels or HUD counters changed.
Sourcepub fn present_to_surface(
&mut self,
scene: &Scene3D,
viewport: Option<[f32; 4]>,
draw_overlay: bool,
) -> Result<(), String>
pub fn present_to_surface( &mut self, scene: &Scene3D, viewport: Option<[f32; 4]>, draw_overlay: bool, ) -> Result<(), String>
Presents scene directly to the swapchain surface and composites cached 2D UI overlay if enabled.
Sourcepub fn present_viewports_to_surface(
&mut self,
viewports: &[([f32; 4], &Scene3D)],
draw_overlay: bool,
) -> Result<(), String>
pub fn present_viewports_to_surface( &mut self, viewports: &[([f32; 4], &Scene3D)], draw_overlay: bool, ) -> Result<(), String>
Presents one or more 3D viewports directly into the single swapchain frame and composites the cached 2D UI overlay once on top before presenting.
Sourcepub fn render_offscreen_bgra(
&mut self,
scene: &Scene3D,
width: u32,
height: u32,
readback: bool,
) -> Result<Vec<u8>, String>
pub fn render_offscreen_bgra( &mut self, scene: &Scene3D, width: u32, height: u32, readback: bool, ) -> Result<Vec<u8>, String>
Offscreen render returning BGRA8 pixels (or empty vec if readback == false).