Skip to content

Commit a02f34f

Browse files
committed
working v1
1 parent d56013b commit a02f34f

4 files changed

Lines changed: 21 additions & 34 deletions

File tree

crates/processing_glfw/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,11 @@ impl GlfwContext {
304304
let scale = self.content_scale();
305305
let logical_w = ((width as f32) / scale).max(1.0) as i32;
306306
let logical_h = ((height as f32) / scale).max(1.0) as i32;
307-
if logical_w != width || logical_h != height {
308-
// processing_render::surface_resize(
309-
// surface,
310-
// logical_w as u32,
311-
// logical_h as u32,
312-
// )
313-
// .unwrap();
314-
}
307+
processing_render::surface_resize(
308+
surface,
309+
logical_w as u32,
310+
logical_h as u32,
311+
).unwrap();
315312
}
316313
_ => {}
317314
}

crates/processing_pyo3/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,10 @@ pub(crate) fn reset_tracked_globals() {
121121
fn sync_globals(module: &Bound<'_, PyModule>, globals: &Bound<'_, PyAny>) -> PyResult<()> {
122122
let graphics =
123123
get_graphics(module)?.ok_or_else(|| PyRuntimeError::new_err("call size() first"))?;
124-
// let width = ::processing::prelude::surface_logical_width(graphics.surface.entity)
125-
// .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
126-
// let height = ::processing::prelude::surface_logical_height(graphics.surface.entity)
127-
// .map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
128-
let width = graphics.width;
129-
let height = graphics.height;
124+
let width = ::processing::prelude::surface_logical_width(graphics.surface.entity)
125+
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
126+
let height = ::processing::prelude::surface_logical_height(graphics.surface.entity)
127+
.map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
130128
input::sync_globals(globals, graphics.surface.entity, width, height)?;
131129
surface::sync_globals(globals, &graphics.surface, width, height)?;
132130
time::sync_globals(globals)?;

crates/processing_render/src/graphics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ impl CameraProjection for ProcessingProjection {
118118
// this gets called with the render target's physical dimensions (i.e. accounting for
119119
// scale factor), but our projection is in logical pixel units
120120
// TODO: handle resizes?
121-
// self.width = _width;
122-
// self.height = _height;
121+
self.width = _width;
122+
self.height = _height;
123123
}
124124

125125
fn far(&self) -> f32 {

crates/processing_render/src/surface.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,6 @@ pub fn resize(
403403
let width = width.max(1);
404404
let height = height.max(1);
405405

406-
// let Ok(window) = windows.get_mut(window_entity) else {
407-
// return Ok(());
408-
// };
409-
//
410-
// if window.mode != WindowMode::Windowed {
411-
// return Ok(());
412-
// }
413-
414406
if let Ok(mut window) = windows.get_mut(window_entity) {
415407
let scale = window.resolution.scale_factor();
416408
let physical_w = (width as f32 * scale) as u32;
@@ -420,16 +412,16 @@ pub fn resize(
420412
.set_physical_resolution(physical_w, physical_h);
421413
}
422414

423-
// for (target, mut surface_size, mut projection) in graphics_query.iter_mut() {
424-
// if let RenderTarget::Window(WindowRef::Entity(surface)) = *target {
425-
// if surface == window_entity {
426-
// *surface_size = SurfaceSize(width, height);
427-
// if let Projection::Custom(ref mut custom) = *projection {
428-
// custom.update(width as f32, height as f32);
429-
// }
430-
// }
431-
// }
432-
// }
415+
for (target, mut surface_size, mut projection) in graphics_query.iter_mut() {
416+
if let RenderTarget::Window(WindowRef::Entity(surface)) = *target {
417+
if surface == window_entity {
418+
*surface_size = SurfaceSize(width, height);
419+
if let Projection::Custom(ref mut custom) = *projection {
420+
custom.update(width as f32, height as f32);
421+
}
422+
}
423+
}
424+
}
433425
Ok(())
434426
}
435427

0 commit comments

Comments
 (0)