Skip to content

Commit 88d9f70

Browse files
committed
Fix draw state to be spawned on window.
1 parent cb6d9ca commit 88d9f70

File tree

3 files changed

+109
-126
lines changed

3 files changed

+109
-126
lines changed

crates/processing_render/src/graphics.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

315328
pub fn flush(app: &mut App, entity: Entity) -> Result<()> {

crates/processing_render/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ pub fn graphics_create(surface_entity: Entity, width: u32, height: u32) -> error
228228
}
229229

230230
/// Begin a new draw pass for the graphics surface.
231-
pub fn graphics_begin_draw(_graphics_entity: Entity) -> error::Result<()> {
232-
app_mut(|app| graphics::begin_draw(app, _graphics_entity))
231+
pub fn graphics_begin_draw(graphics_entity: Entity) -> error::Result<()> {
232+
app_mut(|app| graphics::begin_draw(app.world_mut(), graphics_entity))
233233
}
234234

235235
/// Flush current pending draw commands to the graphics surface.

0 commit comments

Comments
 (0)