2121use bevy:: {
2222 app:: { App , Plugin } ,
2323 asset:: Assets ,
24+ camera:: { CameraProjection , Projection , RenderTarget } ,
2425 ecs:: query:: QueryEntityError ,
2526 math:: { IRect , IVec2 } ,
2627 prelude:: { Commands , Component , Entity , In , Query , ResMut , Window , With , default} ,
2728 render:: render_resource:: { Extent3d , TextureFormat } ,
2829 window:: {
2930 CompositeAlphaMode , Monitor , RawHandleWrapper , WindowLevel , WindowMode , WindowPosition ,
30- WindowResolution , WindowWrapper ,
31+ WindowRef , WindowResolution , WindowWrapper ,
3132 } ,
3233} ;
3334use raw_window_handle:: {
@@ -39,7 +40,10 @@ use processing_core::error::{self, ProcessingError, Result};
3940#[ cfg( not( target_os = "windows" ) ) ]
4041use std:: ptr:: NonNull ;
4142
42- use crate :: image:: Image ;
43+ use crate :: {
44+ graphics:: { ProcessingProjection , SurfaceSize } ,
45+ image:: Image ,
46+ } ;
4347
4448#[ derive( Component , Debug , Clone ) ]
4549pub struct Surface ;
@@ -394,7 +398,19 @@ pub fn destroy(
394398pub fn resize (
395399 In ( ( window_entity, width, height) ) : In < ( Entity , u32 , u32 ) > ,
396400 mut windows : Query < & mut Window > ,
401+ mut graphics_query : Query < ( & RenderTarget , & mut SurfaceSize , & mut Projection ) > ,
397402) -> Result < ( ) > {
403+ let width = width. max ( 1 ) ;
404+ let height = height. max ( 1 ) ;
405+
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+
398414 if let Ok ( mut window) = windows. get_mut ( window_entity) {
399415 let scale = window. resolution . scale_factor ( ) ;
400416 let physical_w = ( width as f32 * scale) as u32 ;
@@ -403,6 +419,17 @@ pub fn resize(
403419 . resolution
404420 . set_physical_resolution ( physical_w, physical_h) ;
405421 }
422+
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+ // }
406433 Ok ( ( ) )
407434}
408435
@@ -448,6 +475,20 @@ pub fn physical_height(In(entity): In<Entity>, query: Query<&Window>) -> u32 {
448475 . unwrap_or ( 0 )
449476}
450477
478+ pub fn logical_width ( In ( entity) : In < Entity > , query : Query < & Window > ) -> u32 {
479+ query
480+ . get ( entity)
481+ . map ( |w| w. resolution . width ( ) as u32 )
482+ . unwrap_or ( 0 )
483+ }
484+
485+ pub fn logical_height ( In ( entity) : In < Entity > , query : Query < & Window > ) -> u32 {
486+ query
487+ . get ( entity)
488+ . map ( |w| w. resolution . height ( ) as u32 )
489+ . unwrap_or ( 0 )
490+ }
491+
451492pub fn set_title (
452493 In ( ( entity, title) ) : In < ( Entity , String ) > ,
453494 mut windows : Query < & mut Window > ,
0 commit comments