@@ -29,7 +29,7 @@ use crate::{
2929 Flush ,
3030 error:: { ProcessingError , Result } ,
3131 image:: { Image , bytes_to_pixels, create_readback_buffer, pixel_size, pixels_to_bytes} ,
32- render:: command:: { CommandBuffer , DrawCommand } ,
32+ render:: { RenderState , command:: { CommandBuffer , DrawCommand } } ,
3333 surface:: Surface ,
3434} ;
3535
@@ -246,6 +246,7 @@ pub fn create(
246246 Transform :: from_xyz ( 0.0 , 0.0 , 999.9 ) ,
247247 render_layer,
248248 CommandBuffer :: new ( ) ,
249+ RenderState :: default ( ) ,
249250 SurfaceSize ( width, height) ,
250251 Graphics {
251252 readback_buffer,
@@ -307,9 +308,21 @@ pub fn destroy(world: &mut World, entity: Entity) -> Result<()> {
307308 world. run_system_cached_with ( destroy_inner, entity) . unwrap ( )
308309}
309310
310- pub fn begin_draw ( _app : & mut App , _entity : Entity ) -> Result < ( ) > {
311- // nothing to do here for now
312- Ok ( ( ) )
311+ pub fn begin_draw ( world : & mut World , entity : Entity ) -> Result < ( ) > {
312+ fn begin_draw_inner (
313+ In ( entity) : In < Entity > ,
314+ mut state_query : Query < & mut RenderState > ,
315+ ) -> Result < ( ) > {
316+ let mut state = state_query
317+ . get_mut ( entity)
318+ . map_err ( |_| ProcessingError :: GraphicsNotFound ) ?;
319+ state. reset ( ) ;
320+ Ok ( ( ) )
321+ }
322+
323+ world
324+ . run_system_cached_with ( begin_draw_inner, entity)
325+ . unwrap ( )
313326}
314327
315328pub fn flush ( app : & mut App , entity : Entity ) -> Result < ( ) > {
0 commit comments