Skip to content

Commit

Permalink
Make From generic
Browse files Browse the repository at this point in the history
  • Loading branch information
bvssvni committed Jun 4, 2015
2 parents 804b848 + 657a3a8 commit 95dc181
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "piston_window"
version = "0.1.0"
version = "0.2.0"
authors = ["bvssvni <[email protected]>"]
keywords = ["window", "piston"]
description = "The official Piston window back-end for the Piston game engine"
Expand Down
14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ type Glyphs = gfx_graphics::GlyphCache<gfx_device_gl::Resources, gfx_device_gl::
/// 2D graphics.
type G2d<'a> = GfxGraphics<'a, gfx_device_gl::Resources, gfx_device_gl::CommandBuffer, gfx_device_gl::Output>;

/// Creates a window using default window back-end.
pub fn window(settings: WindowSettings) -> Rc<RefCell<GlutinWindow>> {
Rc::new(RefCell::new(GlutinWindow::new(settings)))
}

/// Contains everything required for controlling window, graphics, event loop.
pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
/// The window.
Expand All @@ -57,9 +52,12 @@ pub struct PistonWindow<W: window::Window = GlutinWindow, T = ()> {
pub factory: Rc<RefCell<gfx_device_gl::Factory>>,
}

impl From<WindowSettings> for PistonWindow {
fn from(settings: WindowSettings) -> PistonWindow {
PistonWindow::new(window(settings), empty_app())
impl<T> From<WindowSettings> for PistonWindow<T>
where T: Window + OpenGLWindow + From<WindowSettings>,
T::Event: GenericEvent
{
fn from(settings: WindowSettings) -> PistonWindow<T> {
PistonWindow::new(Rc::new(RefCell::new(settings.into())), empty_app())
}
}

Expand Down

0 comments on commit 95dc181

Please sign in to comment.