Skip to main content

RenderPassBuilder

Struct RenderPassBuilder 

Source
pub struct RenderPassBuilder<'f, 'w> { /* private fields */ }
Expand description

Builder for creating render passes with fluent API.

§Example

let mut pass = frame.render_pass()
    .clear_color(Color::BLACK)
    .clear_depth(0.0)
    .label("main")
    .build();

// Use pass.wgpu_pass() for rendering

Implementations§

Source§

impl<'f, 'w> RenderPassBuilder<'f, 'w>

Source

pub fn target(self, target: RenderTarget<'f>) -> Self

Set the render target (for backwards compatibility).

Examples found in repository?
examples/renderer_api.rs (line 307)
284    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
285        if window_id != self.window_id {
286            return;
287        }
288
289        // Handle window-specific resize events
290        events.dispatch(|event| {
291            if let astrelis_winit::event::Event::WindowResized(size) = event {
292                self.window.resized(*size);
293                astrelis_winit::event::HandleStatus::consumed()
294            } else {
295                astrelis_winit::event::HandleStatus::ignored()
296            }
297        });
298
299        let Some(frame) = self.window.begin_frame() else {
300            return; // Surface not available
301        };
302
303        // Pass 1: Render to offscreen framebuffer
304        {
305            let mut pass = frame
306                .render_pass()
307                .target(RenderTarget::Framebuffer(&self.offscreen_fb))
308                .clear_color(Color::rgb(0.2, 0.1, 0.3))
309                .label("offscreen_pass")
310                .build();
311            pass.set_pipeline(&self.pipeline);
312            pass.set_bind_group(0, &self.bind_group, &[]);
313            pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
314            pass.draw(0..6, 0..1);
315        }
316
317        // Pass 2: Blit framebuffer to surface
318        {
319            let mut pass = frame
320                .render_pass()
321                .clear_color(Color::rgb(0.1, 0.2, 0.3))
322                .label("blit_pass")
323                .build();
324            pass.set_pipeline(&self.blit_pipeline);
325            pass.set_bind_group(0, &self.blit_bind_group, &[]);
326            // Draw fullscreen triangle
327            pass.draw(0..3, 0..1);
328        }
329        // Frame auto-submits on drop
330    }
Source

pub fn to_surface(self) -> Self

Render to the window surface (default).

Source

pub fn to_framebuffer(self, fb: &'f Framebuffer) -> Self

Render to a framebuffer.

Source

pub fn to_texture(self, view: &'f TextureView) -> Self

Render to a custom texture view.

Source

pub fn clear_color(self, color: impl Into<ColorOp>) -> Self

Clear the color target to the specified color.

Examples found in repository?
examples/camera_demo.rs (line 109)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("camera_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
More examples
Hide additional examples
examples/mesh_primitives.rs (line 111)
91    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
92        if window_id != self.window_id {
93            return;
94        }
95
96        events.dispatch(|event| {
97            if let astrelis_winit::event::Event::WindowResized(size) = event {
98                self.window.resized(*size);
99                astrelis_winit::event::HandleStatus::consumed()
100            } else {
101                astrelis_winit::event::HandleStatus::ignored()
102            }
103        });
104
105        let Some(frame) = self.window.begin_frame() else {
106            return; // Surface not available
107        };
108        {
109            let _pass = frame
110                .render_pass()
111                .clear_color(Color::from_rgb_u8(20, 30, 40))
112                .label("mesh_primitives_pass")
113                .build();
114        }
115        // Frame auto-submits on drop
116    }
examples/render_graph_demo.rs (line 109)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("render_graph_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
examples/window_manager_demo.rs (line 109)
86    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
87        // Get the color for this window
88        let Some(&color) = self.window_colors.get(&window_id) else {
89            return;
90        };
91
92        // WindowManager automatically handles:
93        // 1. Window lookup (no manual HashMap.get_mut)
94        // 2. Resize events (automatic)
95        // 3. Event dispatching
96        self.window_manager
97            .render_window(window_id, events, |window, _events| {
98                // No need to manually handle resize events!
99                // WindowManager already did that for us
100
101                // Just render!
102                let Some(frame) = window.begin_frame() else {
103                    return; // Surface not available
104                };
105
106                {
107                    let _pass = frame
108                        .render_pass()
109                        .clear_color(color)
110                        .label("window_manager_pass")
111                        .build();
112                    // Additional rendering would go here
113                }
114                // Frame auto-submits on drop
115            });
116    }
examples/material_system.rs (line 132)
105    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
106        if window_id != self.window_id {
107            return;
108        }
109
110        // Handle resize
111        events.dispatch(|event| {
112            if let astrelis_winit::event::Event::WindowResized(size) = event {
113                self.window.resized(*size);
114                astrelis_winit::event::HandleStatus::consumed()
115            } else {
116                astrelis_winit::event::HandleStatus::ignored()
117            }
118        });
119
120        // In a real application, materials would be bound during rendering:
121        // material.bind(&mut render_pass);
122        // draw_mesh(&mesh);
123
124        // Begin frame
125        let Some(frame) = self.window.begin_frame() else {
126            return; // Surface not available
127        };
128
129        {
130            let _pass = frame
131                .render_pass()
132                .clear_color(Color::from_rgb_u8(20, 30, 40))
133                .label("material_system_pass")
134                .build();
135            // Materials would be applied here in actual rendering
136            // This is a conceptual demonstration
137        }
138        // Frame auto-submits on drop
139    }
examples/sprite_sheet.rs (line 457)
431    fn render(
432        &mut self,
433        _ctx: &mut astrelis_winit::app::AppCtx,
434        window_id: WindowId,
435        events: &mut astrelis_winit::event::EventBatch,
436    ) {
437        let Some(window) = self.windows.get_mut(&window_id) else {
438            return;
439        };
440
441        // Handle resize
442        events.dispatch(|event| {
443            if let astrelis_winit::event::Event::WindowResized(size) = event {
444                window.resized(*size);
445                astrelis_winit::event::HandleStatus::consumed()
446            } else {
447                astrelis_winit::event::HandleStatus::ignored()
448            }
449        });
450
451        let Some(frame) = window.begin_frame() else {
452            return; // Surface not available
453        };
454        {
455            let mut pass = frame
456                .render_pass()
457                .clear_color(Color::rgb(0.1, 0.1, 0.15))
458                .label("sprite_sheet_pass")
459                .build();
460            pass.set_pipeline(&self.pipeline);
461            pass.set_bind_group(0, &self.bind_group, &[]);
462            pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
463            pass.draw(0..6, 0..1);
464        }
465        // Frame auto-submits on drop
466    }
Source

pub fn load_color(self) -> Self

Load existing color contents (default).

Source

pub fn depth_attachment(self, view: &'f TextureView) -> Self

Set the depth attachment.

Examples found in repository?
examples/batched_renderer.rs (line 437)
370    fn render(
371        &mut self,
372        _ctx: &mut astrelis_winit::app::AppCtx,
373        window_id: WindowId,
374        events: &mut astrelis_winit::event::EventBatch,
375    ) {
376        // Handle resize and get dimensions (scoped to release window borrow)
377        let (phys_width, phys_height) = {
378            let Some(window) = self.windows.get_mut(&window_id) else {
379                return;
380            };
381
382            events.dispatch(|event| {
383                if let astrelis_winit::event::Event::WindowResized(size) = event {
384                    window.resized(*size);
385                    astrelis_winit::event::HandleStatus::consumed()
386                } else {
387                    astrelis_winit::event::HandleStatus::ignored()
388                }
389            });
390
391            let phys = window.physical_size();
392            (phys.width, phys.height)
393        };
394
395        let width = phys_width as f32;
396        let height = phys_height as f32;
397
398        if width < 1.0 || height < 1.0 {
399            return;
400        }
401
402        // Ensure depth buffer matches viewport
403        self.ensure_depth_buffer(phys_width, phys_height);
404
405        // Build instances and prepare GPU data
406        let instances = self.build_instances(width, height);
407        let batch = DrawBatch2D {
408            instances,
409            textures: vec![],
410            projection: Self::ortho_projection(width, height),
411        };
412        self.renderer.prepare(&batch);
413
414        let stats = self.renderer.stats();
415        if self.frame_count % 120 == 0 {
416            tracing::info!(
417                "Frame {}: {} instances ({} opaque, {} transparent), {} draw calls",
418                self.frame_count,
419                stats.instance_count,
420                stats.opaque_count,
421                stats.transparent_count,
422                stats.draw_calls,
423            );
424        }
425
426        // Re-borrow window for rendering
427        let window = self.windows.get_mut(&window_id).unwrap();
428        let Some(frame) = window.begin_frame() else {
429            return; // Surface not available
430        };
431
432        // Create render pass with depth stencil attachment
433        {
434            let mut pass = frame
435                .render_pass()
436                .clear_color(Color::rgba(0.08, 0.08, 0.1, 1.0))
437                .depth_attachment(&self.depth_view)
438                .clear_depth(0.0) // 0.0 = far with GreaterEqual
439                .label("batched_example_pass")
440                .build();
441            self.renderer.render(pass.wgpu_pass());
442        }
443        // Frame auto-submits on drop
444    }
Source

pub fn with_window_depth(self) -> Self

Use the window’s depth buffer automatically.

§Panics

Panics if the window doesn’t have a depth buffer.

Source

pub fn with_window_depth_if_available(self) -> Self

Use the window’s depth buffer if available.

Source

pub fn clear_depth(self, value: f32) -> Self

Clear the depth buffer to the specified value.

Examples found in repository?
examples/batched_renderer.rs (line 438)
370    fn render(
371        &mut self,
372        _ctx: &mut astrelis_winit::app::AppCtx,
373        window_id: WindowId,
374        events: &mut astrelis_winit::event::EventBatch,
375    ) {
376        // Handle resize and get dimensions (scoped to release window borrow)
377        let (phys_width, phys_height) = {
378            let Some(window) = self.windows.get_mut(&window_id) else {
379                return;
380            };
381
382            events.dispatch(|event| {
383                if let astrelis_winit::event::Event::WindowResized(size) = event {
384                    window.resized(*size);
385                    astrelis_winit::event::HandleStatus::consumed()
386                } else {
387                    astrelis_winit::event::HandleStatus::ignored()
388                }
389            });
390
391            let phys = window.physical_size();
392            (phys.width, phys.height)
393        };
394
395        let width = phys_width as f32;
396        let height = phys_height as f32;
397
398        if width < 1.0 || height < 1.0 {
399            return;
400        }
401
402        // Ensure depth buffer matches viewport
403        self.ensure_depth_buffer(phys_width, phys_height);
404
405        // Build instances and prepare GPU data
406        let instances = self.build_instances(width, height);
407        let batch = DrawBatch2D {
408            instances,
409            textures: vec![],
410            projection: Self::ortho_projection(width, height),
411        };
412        self.renderer.prepare(&batch);
413
414        let stats = self.renderer.stats();
415        if self.frame_count % 120 == 0 {
416            tracing::info!(
417                "Frame {}: {} instances ({} opaque, {} transparent), {} draw calls",
418                self.frame_count,
419                stats.instance_count,
420                stats.opaque_count,
421                stats.transparent_count,
422                stats.draw_calls,
423            );
424        }
425
426        // Re-borrow window for rendering
427        let window = self.windows.get_mut(&window_id).unwrap();
428        let Some(frame) = window.begin_frame() else {
429            return; // Surface not available
430        };
431
432        // Create render pass with depth stencil attachment
433        {
434            let mut pass = frame
435                .render_pass()
436                .clear_color(Color::rgba(0.08, 0.08, 0.1, 1.0))
437                .depth_attachment(&self.depth_view)
438                .clear_depth(0.0) // 0.0 = far with GreaterEqual
439                .label("batched_example_pass")
440                .build();
441            self.renderer.render(pass.wgpu_pass());
442        }
443        // Frame auto-submits on drop
444    }
Source

pub fn load_depth(self) -> Self

Load existing depth values.

Source

pub fn depth_readonly(self) -> Self

Use depth in read-only mode (no writes).

Source

pub fn label(self, name: impl Into<String>) -> Self

Set a debug label for the render pass.

Examples found in repository?
examples/camera_demo.rs (line 110)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("camera_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
More examples
Hide additional examples
examples/mesh_primitives.rs (line 112)
91    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
92        if window_id != self.window_id {
93            return;
94        }
95
96        events.dispatch(|event| {
97            if let astrelis_winit::event::Event::WindowResized(size) = event {
98                self.window.resized(*size);
99                astrelis_winit::event::HandleStatus::consumed()
100            } else {
101                astrelis_winit::event::HandleStatus::ignored()
102            }
103        });
104
105        let Some(frame) = self.window.begin_frame() else {
106            return; // Surface not available
107        };
108        {
109            let _pass = frame
110                .render_pass()
111                .clear_color(Color::from_rgb_u8(20, 30, 40))
112                .label("mesh_primitives_pass")
113                .build();
114        }
115        // Frame auto-submits on drop
116    }
examples/render_graph_demo.rs (line 110)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("render_graph_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
examples/window_manager_demo.rs (line 110)
86    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
87        // Get the color for this window
88        let Some(&color) = self.window_colors.get(&window_id) else {
89            return;
90        };
91
92        // WindowManager automatically handles:
93        // 1. Window lookup (no manual HashMap.get_mut)
94        // 2. Resize events (automatic)
95        // 3. Event dispatching
96        self.window_manager
97            .render_window(window_id, events, |window, _events| {
98                // No need to manually handle resize events!
99                // WindowManager already did that for us
100
101                // Just render!
102                let Some(frame) = window.begin_frame() else {
103                    return; // Surface not available
104                };
105
106                {
107                    let _pass = frame
108                        .render_pass()
109                        .clear_color(color)
110                        .label("window_manager_pass")
111                        .build();
112                    // Additional rendering would go here
113                }
114                // Frame auto-submits on drop
115            });
116    }
examples/material_system.rs (line 133)
105    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
106        if window_id != self.window_id {
107            return;
108        }
109
110        // Handle resize
111        events.dispatch(|event| {
112            if let astrelis_winit::event::Event::WindowResized(size) = event {
113                self.window.resized(*size);
114                astrelis_winit::event::HandleStatus::consumed()
115            } else {
116                astrelis_winit::event::HandleStatus::ignored()
117            }
118        });
119
120        // In a real application, materials would be bound during rendering:
121        // material.bind(&mut render_pass);
122        // draw_mesh(&mesh);
123
124        // Begin frame
125        let Some(frame) = self.window.begin_frame() else {
126            return; // Surface not available
127        };
128
129        {
130            let _pass = frame
131                .render_pass()
132                .clear_color(Color::from_rgb_u8(20, 30, 40))
133                .label("material_system_pass")
134                .build();
135            // Materials would be applied here in actual rendering
136            // This is a conceptual demonstration
137        }
138        // Frame auto-submits on drop
139    }
examples/sprite_sheet.rs (line 458)
431    fn render(
432        &mut self,
433        _ctx: &mut astrelis_winit::app::AppCtx,
434        window_id: WindowId,
435        events: &mut astrelis_winit::event::EventBatch,
436    ) {
437        let Some(window) = self.windows.get_mut(&window_id) else {
438            return;
439        };
440
441        // Handle resize
442        events.dispatch(|event| {
443            if let astrelis_winit::event::Event::WindowResized(size) = event {
444                window.resized(*size);
445                astrelis_winit::event::HandleStatus::consumed()
446            } else {
447                astrelis_winit::event::HandleStatus::ignored()
448            }
449        });
450
451        let Some(frame) = window.begin_frame() else {
452            return; // Surface not available
453        };
454        {
455            let mut pass = frame
456                .render_pass()
457                .clear_color(Color::rgb(0.1, 0.1, 0.15))
458                .label("sprite_sheet_pass")
459                .build();
460            pass.set_pipeline(&self.pipeline);
461            pass.set_bind_group(0, &self.bind_group, &[]);
462            pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
463            pass.draw(0..6, 0..1);
464        }
465        // Frame auto-submits on drop
466    }
Source

pub fn build(self) -> RenderPass<'f>

Build and return the render pass.

The pass owns its encoder. When dropped, it ends the pass, finishes the encoder, and adds the command buffer to the frame.

Examples found in repository?
examples/camera_demo.rs (line 111)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("camera_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
More examples
Hide additional examples
examples/mesh_primitives.rs (line 113)
91    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
92        if window_id != self.window_id {
93            return;
94        }
95
96        events.dispatch(|event| {
97            if let astrelis_winit::event::Event::WindowResized(size) = event {
98                self.window.resized(*size);
99                astrelis_winit::event::HandleStatus::consumed()
100            } else {
101                astrelis_winit::event::HandleStatus::ignored()
102            }
103        });
104
105        let Some(frame) = self.window.begin_frame() else {
106            return; // Surface not available
107        };
108        {
109            let _pass = frame
110                .render_pass()
111                .clear_color(Color::from_rgb_u8(20, 30, 40))
112                .label("mesh_primitives_pass")
113                .build();
114        }
115        // Frame auto-submits on drop
116    }
examples/render_graph_demo.rs (line 111)
89    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
90        if window_id != self.window_id {
91            return;
92        }
93
94        events.dispatch(|event| {
95            if let astrelis_winit::event::Event::WindowResized(size) = event {
96                self.window.resized(*size);
97                astrelis_winit::event::HandleStatus::consumed()
98            } else {
99                astrelis_winit::event::HandleStatus::ignored()
100            }
101        });
102
103        let Some(frame) = self.window.begin_frame() else {
104            return; // Surface not available
105        };
106        {
107            let _pass = frame
108                .render_pass()
109                .clear_color(Color::from_rgb_u8(20, 30, 40))
110                .label("render_graph_demo_pass")
111                .build();
112        }
113        // Frame auto-submits on drop
114    }
examples/window_manager_demo.rs (line 111)
86    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
87        // Get the color for this window
88        let Some(&color) = self.window_colors.get(&window_id) else {
89            return;
90        };
91
92        // WindowManager automatically handles:
93        // 1. Window lookup (no manual HashMap.get_mut)
94        // 2. Resize events (automatic)
95        // 3. Event dispatching
96        self.window_manager
97            .render_window(window_id, events, |window, _events| {
98                // No need to manually handle resize events!
99                // WindowManager already did that for us
100
101                // Just render!
102                let Some(frame) = window.begin_frame() else {
103                    return; // Surface not available
104                };
105
106                {
107                    let _pass = frame
108                        .render_pass()
109                        .clear_color(color)
110                        .label("window_manager_pass")
111                        .build();
112                    // Additional rendering would go here
113                }
114                // Frame auto-submits on drop
115            });
116    }
examples/material_system.rs (line 134)
105    fn render(&mut self, _ctx: &mut AppCtx, window_id: WindowId, events: &mut EventBatch) {
106        if window_id != self.window_id {
107            return;
108        }
109
110        // Handle resize
111        events.dispatch(|event| {
112            if let astrelis_winit::event::Event::WindowResized(size) = event {
113                self.window.resized(*size);
114                astrelis_winit::event::HandleStatus::consumed()
115            } else {
116                astrelis_winit::event::HandleStatus::ignored()
117            }
118        });
119
120        // In a real application, materials would be bound during rendering:
121        // material.bind(&mut render_pass);
122        // draw_mesh(&mesh);
123
124        // Begin frame
125        let Some(frame) = self.window.begin_frame() else {
126            return; // Surface not available
127        };
128
129        {
130            let _pass = frame
131                .render_pass()
132                .clear_color(Color::from_rgb_u8(20, 30, 40))
133                .label("material_system_pass")
134                .build();
135            // Materials would be applied here in actual rendering
136            // This is a conceptual demonstration
137        }
138        // Frame auto-submits on drop
139    }
examples/sprite_sheet.rs (line 459)
431    fn render(
432        &mut self,
433        _ctx: &mut astrelis_winit::app::AppCtx,
434        window_id: WindowId,
435        events: &mut astrelis_winit::event::EventBatch,
436    ) {
437        let Some(window) = self.windows.get_mut(&window_id) else {
438            return;
439        };
440
441        // Handle resize
442        events.dispatch(|event| {
443            if let astrelis_winit::event::Event::WindowResized(size) = event {
444                window.resized(*size);
445                astrelis_winit::event::HandleStatus::consumed()
446            } else {
447                astrelis_winit::event::HandleStatus::ignored()
448            }
449        });
450
451        let Some(frame) = window.begin_frame() else {
452            return; // Surface not available
453        };
454        {
455            let mut pass = frame
456                .render_pass()
457                .clear_color(Color::rgb(0.1, 0.1, 0.15))
458                .label("sprite_sheet_pass")
459                .build();
460            pass.set_pipeline(&self.pipeline);
461            pass.set_bind_group(0, &self.bind_group, &[]);
462            pass.set_vertex_buffer(0, self.vertex_buffer.slice(..));
463            pass.draw(0..6, 0..1);
464        }
465        // Frame auto-submits on drop
466    }

Auto Trait Implementations§

§

impl<'f, 'w> Freeze for RenderPassBuilder<'f, 'w>

§

impl<'f, 'w> !RefUnwindSafe for RenderPassBuilder<'f, 'w>

§

impl<'f, 'w> !Send for RenderPassBuilder<'f, 'w>

§

impl<'f, 'w> !Sync for RenderPassBuilder<'f, 'w>

§

impl<'f, 'w> Unpin for RenderPassBuilder<'f, 'w>

§

impl<'f, 'w> !UnwindSafe for RenderPassBuilder<'f, 'w>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more