help about hello_world
adjivas opened this issue · 0 comments
adjivas commented
Hello,
I work with src/hello_world.rs file and try to use text::Text::new_color in my function but my prototype/code isn't valid:
Please, can you inform me about the good prototype to use for resolve my problem?
extern crate piston_window;
extern crate find_folder;
use piston_window::*;
fn draw<G: Graphics> (
glyphs: &mut Glyphs,
c: &Context,
g: &mut G,
) {
let transform = c.transform.trans(10.0, 100.0);
text::Text::new_color([0.0, 1.0, 0.0, 1.0], 32).draw (
"Hello world!",
glyphs,
&c.draw_state,
transform, g
);
}
fn main() {
let window: PistonWindow = WindowSettings::new(
"piston: hello_world",
[200, 200]
)
.exit_on_esc(true)
//.opengl(OpenGL::V2_1) // Set a different OpenGl version
.build()
.unwrap();
let assets = find_folder::Search::ParentsThenKids(3, 3)
.for_folder("assets").unwrap();
println!("{:?}", assets);
let ref font = assets.join("FiraSans-Regular.ttf");
let factory = window.factory.borrow().clone();
let mut glyphs = Glyphs::new(font, factory).unwrap();
for e in window {
e.draw_2d(|c, g| {
draw(&mut glyphs, &c, g);
});
}
}
The problem/error:
adjivas:/tmp/piston-examples/ cargo run --bin hello_world
Compiling piston-examples v0.0.0 (file:///private/tmp/piston-examples)
src/hello_world.rs:13:53: 18:6 error: type mismatch resolving `<G as graphics::graphics::Graphics>::Texture == gfx_texture::Texture<gfx_device_gl::Resources>`:
expected associated type,
found struct `gfx_texture::Texture` [E0271]
src/hello_world.rs:13 text::Text::new_color([0.0, 1.0, 0.0, 1.0], 32).draw (
src/hello_world.rs:14 "Hello world!",
src/hello_world.rs:15 glyphs,
src/hello_world.rs:16 &c.draw_state,
src/hello_world.rs:17 transform, g
src/hello_world.rs:18 );
src/hello_world.rs:13:53: 18:6 help: run `rustc --explain E0271` to see a detailed explanation
error: aborting due to previous error
Could not compile `piston-examples`.
To learn more, run the command again with --verbose.