File tree 4 files changed +26
-0
lines changed
4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ git = "https://github.com/PistonDevelopers/piston"
27
27
28
28
git = " https://github.com/bjz/gl-rs"
29
29
30
+ [dependencies .gfx ]
31
+
32
+ git = " https://github.com/gfx-rs/gfx-rs"
33
+
30
34
[[lib ]]
31
35
32
36
name = " sdl2_game_window"
Original file line number Diff line number Diff line change 1
1
//! RenderWindow and ConcurrentWindow implemented by SDL2 back-end.
2
2
3
3
// External crates.
4
+ use gfx;
5
+ use gfx:: DeviceHelper ;
6
+ use device;
4
7
use std;
5
8
use sdl2;
6
9
use piston:: {
@@ -145,4 +148,14 @@ impl ConcurrentWindowSDL2 {
145
148
) ;
146
149
147
150
}
151
+
152
+ /// Creates a gfx device and front end.
153
+ pub fn gfx ( & self ) -> ( device:: GlDevice , gfx:: FrontEnd ) {
154
+ let mut device = device:: GlDevice :: new ( |s| unsafe {
155
+ std:: mem:: transmute ( sdl2:: video:: gl_get_proc_address ( s) )
156
+ } ) ;
157
+ let ( w, h) = self . get_size ( ) ;
158
+ let frontend = device. create_frontend ( w as u16 , h as u16 ) . unwrap ( ) ;
159
+ ( device, frontend)
160
+ }
148
161
}
Original file line number Diff line number Diff line change 1
1
//! A window implemented by SDL2 back-end.
2
2
3
3
// External crates.
4
+ use gfx;
5
+ use device;
4
6
use sdl2;
5
7
use piston:: {
6
8
GameWindow ,
@@ -35,6 +37,11 @@ impl GameWindowSDL2 {
35
37
render_window : render_window,
36
38
}
37
39
}
40
+
41
+ /// Creates a gfx devince and front end.
42
+ pub fn gfx ( & self ) -> ( device:: GlDevice , gfx:: FrontEnd ) {
43
+ self . concurrent_window . gfx ( )
44
+ }
38
45
}
39
46
40
47
impl GameWindow for GameWindowSDL2 {
Original file line number Diff line number Diff line change 6
6
extern crate sdl2;
7
7
extern crate piston;
8
8
extern crate gl;
9
+ extern crate gfx;
10
+ extern crate device;
9
11
10
12
pub use GameWindowSDL2 = game_window_sdl2:: GameWindowSDL2 ;
11
13
pub use ConcurrentWindowSDL2 = concurrent_window_sdl2:: ConcurrentWindowSDL2 ;
You can’t perform that action at this time.
0 commit comments