blob: ad96f8fef5c85be2b564d1efa462f0f9a05783b7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
fn main() {
let sdl_context = sdl2::init().expect("Couldn't initialize the SDL2 context!");
let sdl_video = sdl_context
.video()
.expect("Couldn't get the SDL2 video subsystem!");
show_screensaver(sdl_context, sdl_video);
}
fn show_screensaver(sdl_context: sdl2::Sdl, sdl_video: sdl2::VideoSubsystem) {
let window = sdl_video
.window("Kyukai", 10, 10)
.fullscreen()
.build()
.expect("Failed to build the SDL2 window!");
let mut canvas = window
.into_canvas()
.build()
.expect("Couldn't get the SDL2 canvas from the window!");
canvas.set_draw_color(Color::RGB(255, 255, 255));
canvas.clear();
canvas.present();
let mut sdl_event_pump = sdl_context
.event_pump()
.expect("Couldn't get the SDL2 event pump!");
'running: loop {
for event in sdl_event_pump.wait_iter() {
match event {
Event::KeyDown {
keycode: Some(Keycode::Escape),
..
} => {
break 'running;
}
_ => {}
}
}
}
}
|