@@ -36,6 +36,8 @@ pub struct PistonWindow<W: window::Window, T = ()> {
3636 pub event : Option < event:: Event < W :: Event > > ,
3737 /// Application structure.
3838 pub app : Rc < RefCell < T > > ,
39+ /// The factory that was created along with the device.
40+ pub factory : Rc < RefCell < gfx_device_gl:: Factory > > ,
3941}
4042
4143impl < W , T > Clone for PistonWindow < W , T >
@@ -50,6 +52,7 @@ impl<W, T> Clone for PistonWindow<W, T>
5052 events : self . events . clone ( ) ,
5153 event : self . event . clone ( ) ,
5254 app : self . app . clone ( ) ,
55+ factory : self . factory . clone ( ) ,
5356 }
5457 }
5558}
@@ -64,8 +67,8 @@ impl<W, T> PistonWindow<W, T>
6467 use piston:: event:: Events ;
6568 use piston:: window:: { OpenGLWindow , Window } ;
6669
67- let device = gfx_device_gl :: Device :: new ( |s| window . borrow_mut ( ) . get_proc_address ( s ) ) ;
68- let mut factory = device . spawn_factory ( ) ;
70+ let ( device, mut factory ) =
71+ gfx_device_gl :: create ( |s| window . borrow_mut ( ) . get_proc_address ( s ) ) ;
6972
7073 let draw_size = window. borrow ( ) . draw_size ( ) ;
7174 let output = factory. make_fake_output ( draw_size. width as u16 , draw_size. height as u16 ) ;
@@ -82,6 +85,7 @@ impl<W, T> PistonWindow<W, T>
8285 events : Rc :: new ( RefCell :: new ( window. events ( ) ) ) ,
8386 event : None ,
8487 app : app,
88+ factory : Rc :: new ( RefCell :: new ( factory) ) ,
8589 }
8690 }
8791
@@ -95,6 +99,7 @@ impl<W, T> PistonWindow<W, T>
9599 events : self . events ,
96100 event : self . event ,
97101 app : app,
102+ factory : self . factory ,
98103 }
99104 }
100105
@@ -163,6 +168,7 @@ impl<W, T> Iterator for PistonWindow<W, T>
163168 events : self . events . clone ( ) ,
164169 event : Some ( e) ,
165170 app : self . app . clone ( ) ,
171+ factory : self . factory . clone ( ) ,
166172 } )
167173 } else { None }
168174 }
@@ -196,6 +202,7 @@ impl<W, T> event::GenericEvent for PistonWindow<W, T>
196202 events : old_event. events . clone ( ) ,
197203 event : Some ( e) ,
198204 app : old_event. app . clone ( ) ,
205+ factory : old_event. factory . clone ( ) ,
199206 } )
200207 }
201208 None => None
0 commit comments