mirror of
https://github.com/encounter/rust-sdl2.git
synced 2026-07-10 21:18:41 -07:00
fix demo
This commit is contained in:
+3
-3
@@ -31,17 +31,17 @@ pub fn main(filename: &Path) {
|
||||
let font = trying!(sdl2_ttf::Font::from_file(filename, 128));
|
||||
|
||||
// render a surface, and convert it to a texture bound to the renderer
|
||||
let surface = trying!(font.render_str_blended("Hello Rust!", sdl2::pixels::Color::new(255, 0, 0, 255)));
|
||||
let surface = trying!(font.render_str_blended("Hello Rust!", sdl2::pixels::RGBA(255, 0, 0, 255)));
|
||||
let texture = trying!(renderer.create_texture_from_surface(surface));
|
||||
|
||||
renderer.set_draw_color(sdl2::pixels::Color::new(195, 217, 255, 255));
|
||||
renderer.set_draw_color(sdl2::pixels::RGBA(195, 217, 255, 255));
|
||||
renderer.clear();
|
||||
|
||||
let (w, h) = match texture.query() {
|
||||
Ok(q) => (q.width, q.height),
|
||||
Err(err) => fail!(format!("Failed to query texture: {}", err))
|
||||
};
|
||||
renderer.copy(texture, None, Some(rect!((SCREEN_WIDTH - w)/ 2, (SCREEN_HEIGHT - h)/ 2, w, h)));
|
||||
renderer.copy(&texture, None, Some(rect!((SCREEN_WIDTH - w)/ 2, (SCREEN_HEIGHT - h)/ 2, w, h)));
|
||||
|
||||
renderer.present();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user