Created
September 21, 2015 06:07
-
-
Save cjweigle/5f8aedb406cf4652ce78 to your computer and use it in GitHub Desktop.
I get this compilation error trying to use piston sprite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
src/main.rs:42:2: 51:6 note: expansion site | |
src/main.rs:47:19: 47:39 help: run `rustc --explain E0277` to see a detailed explanation | |
src/main.rs:47:19: 47:39 error: the trait `graphics::graphics::Graphics` is not implemented for the type `gfx_graphics::back_end::GfxGraphics<'_, gfx_device_gl::Resources, gfx::device::command::CommandBuffer<gfx_device_gl::Resources>, gfx_device_gl::factory::Output>` [E0277] | |
src/main.rs:47 scene.draw(c.transform, g); | |
^~~~~~~~~~~~~~~~~~~~ | |
**/ | |
extern crate piston_window; | |
extern crate sprite; | |
extern crate find_folder; | |
use piston_window::*; | |
use sprite::*; | |
use std::rc::Rc; | |
#[allow(dead_code)] | |
fn main() { | |
//define the window size | |
let (width, height) = (800, 600); | |
//set the open gl spec level | |
let opengl = OpenGL::V3_2; | |
//create the window | |
let window: PistonWindow = | |
WindowSettings::new("piston: sprite", (width, height)) | |
.exit_on_esc(true) | |
.opengl(opengl) | |
.build() | |
.unwrap(); | |
//find the assets folder | |
let assets = find_folder::Search::ParentsThenKids(3, 3) | |
.for_folder("assets").unwrap(); | |
let mut scene = Scene::new(); | |
let tex = Rc::new(Texture::from_path( | |
&mut *window.factory.borrow_mut(), | |
assets.join("dude.png"), | |
Flip::None, | |
&TextureSettings::new() | |
).unwrap()); | |
let mut sprite = Sprite::from_texture(tex.clone()); | |
sprite.set_position(width as f64 / 2.0, height as f64 / 2.0); | |
let id = scene.add_child(sprite); | |
for e in window { | |
scene.event(&e); | |
e.draw_2d(|c, g| { | |
clear([1.0, 1.0, 1.0, 1.0], g); | |
scene.draw(c.transform, g); | |
}); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment