Skip to content

Commit 094a5c9

Browse files
committed
feat: enabled resizing functionality
Bug found: Resizing with mouse several times causes ERROR wgpu_hal::auxil::dxgi::exception] ID3D12Device::CreateSharedResource: Returning E_OUTOFMEMORY, meaning memory was exhausted. [ STATE_CREATION ERROR #642: CREATERESOURCEANDHEAP_OUTOFMEMORY_RETURN]
1 parent c07f72e commit 094a5c9

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

src/lib.rs

+27-8
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ impl State {
113113
}
114114

115115
fn input(&mut self, event: &WindowEvent) -> bool {
116-
todo!()
116+
println!("State.input(): Unimplemented");
117+
return false;
117118
}
118119

119-
fn update(&mut self) {
120-
todo!()
121-
}
120+
fn update(&mut self) {}
122121

123122
fn render(&mut self) -> Result<(), wgpu::SurfaceError> {
124-
todo!()
123+
println!("State.render(): Unimplemented");
124+
return Ok(());
125125
}
126126
}
127127

@@ -139,9 +139,28 @@ pub async fn run() {
139139
*control_flow = ControlFlow::Wait;
140140
match event {
141141
Event::WindowEvent {
142-
event: WindowEvent::CloseRequested,
143-
..
144-
} => *control_flow = ControlFlow::Exit,
142+
ref event,
143+
window_id,
144+
} if window_id == state.window().id() => {
145+
if !state.input(event) {
146+
match event {
147+
148+
WindowEvent::CloseRequested => {
149+
*control_flow = ControlFlow::Exit;
150+
},
151+
152+
WindowEvent::Resized(physical_size) => {
153+
state.resize(*physical_size);
154+
},
155+
156+
WindowEvent::ScaleFactorChanged { new_inner_size, .. } => {
157+
state.resize(**new_inner_size);
158+
},
159+
160+
_ => {}
161+
}
162+
}
163+
}
145164
_ => {}
146165
}
147166
});

0 commit comments

Comments
 (0)