# How to react on window resize?

**URL:** <https://discourse.piston.rs/t/how-to-react-on-window-resize/175>\
**Category:** Uncategorized\
**Created:** [September 13, 2020, 9:30am UTC](https://discourse.piston.rs/t/how-to-react-on-window-resize/175 "2020-09-13T09:30:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarao](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@amarao](https://discourse.piston.rs/u/amarao)\
**Post date:** [September 13, 2020, 9:30am UTC](https://discourse.piston.rs/t/how-to-react-on-window-resize/175/1 "2020-09-13T09:30:35Z")

</div>

I’m learning both rust and piston at the same time. I made my app (a prototype), and it works, but there are few strange behaviors I can’t explain.

My code is here: [main.rs](https://github.com/amarao/piston_play/blob/e42099ae7dadff377e029af1703512f7765756da/src/main.rs).

The problem with my current code is that resize misbehave terribly.

If window is scaled down, pixels become HUGE. It looks like texture is scaled up at the speed of window been scaled down.  
If window scaled up (made bigger), I see black box around my draw area, even if I recreate both image buffer and texture with new sizes.

I can’t find any high-level docs on how it works (texture/buffer/transformations), so I made this by trial and error, but now I’m stuck. My texture is recreated on resize, my image is recreated, but window is ignoring(?) it.

---

<div class="post-metadata">

**Author:** ![amarao](https://avatars.discourse-cdn.com/v4/letter/a/db5fbb/32.png) [@amarao](https://discourse.piston.rs/u/amarao)\
**Post date:** [September 13, 2020, 10:28am UTC](https://discourse.piston.rs/t/how-to-react-on-window-resize/175/2 "2020-09-13T10:28:55Z")

</div>

Oh, I found it!  
I need to add `window.event(&e);` at the end of event loop!

Sadly, it’s not in examples (I started from [paint.rs](https://github.com/PistonDevelopers/piston-examples/blob/master/src/paint.rs)).
