sdl2/lib.rs
1//! # Getting started
2//!
3//! ```rust,no_run
4//! extern crate sdl2;
5//!
6//! use sdl2::pixels::Color;
7//! use sdl2::event::Event;
8//! use sdl2::keyboard::Keycode;
9//! use std::time::Duration;
10//!
11//! pub fn main() {
12//! let sdl_context = sdl2::init().unwrap();
13//! let video_subsystem = sdl_context.video().unwrap();
14//!
15//! let window = video_subsystem.window("rust-sdl2 demo", 800, 600)
16//! .position_centered()
17//! .build()
18//! .unwrap();
19//!
20//! let mut canvas = window.into_canvas().build().unwrap();
21//!
22//! canvas.set_draw_color(Color::RGB(0, 255, 255));
23//! canvas.clear();
24//! canvas.present();
25//! let mut event_pump = sdl_context.event_pump().unwrap();
26//! let mut i = 0;
27//! 'running: loop {
28//! i = (i + 1) % 255;
29//! canvas.set_draw_color(Color::RGB(i, 64, 255 - i));
30//! canvas.clear();
31//! for event in event_pump.poll_iter() {
32//! match event {
33//! Event::Quit {..} |
34//! Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
35//! break 'running
36//! },
37//! _ => {}
38//! }
39//! }
40//! // The rest of the game loop goes here...
41//!
42//! canvas.present();
43//! ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
44//! }
45//! }
46//! ```
47
48#![crate_name = "sdl2"]
49#![crate_type = "lib"]
50
51#![cfg_attr(feature = "cargo-clippy", allow(cast_lossless, transmute_ptr_to_ref))]
52
53extern crate num;
54pub extern crate libc;
55
56#[macro_use]
57extern crate lazy_static;
58
59#[macro_use]
60extern crate bitflags;
61pub extern crate sdl2_sys as sys;
62
63#[cfg(feature = "gfx")]
64extern crate c_vec;
65
66pub use crate::sdl::*;
67
68pub mod clipboard;
69pub mod cpuinfo;
70#[macro_use] pub mod macros;
71pub mod event;
72pub mod filesystem;
73pub mod gesture;
74pub mod touch;
75pub mod joystick;
76pub mod controller;
77pub mod haptic;
78pub mod keyboard;
79pub mod mouse;
80pub mod rect;
81pub mod surface;
82pub mod pixels;
83pub mod video;
84pub mod timer;
85pub mod render;
86pub mod rwops;
87pub mod log;
88mod sdl;
89pub mod audio;
90pub mod version;
91pub mod messagebox;
92pub mod hint;
93
94// modules
95#[cfg(feature = "ttf")]
96pub mod ttf;
97#[cfg(feature = "image")]
98pub mod image;
99#[cfg(feature = "mixer")]
100pub mod mixer;
101#[cfg(feature = "gfx")]
102pub mod gfx;
103
104mod common;
105// Export return types and such from the common module.
106pub use crate::common::IntegerOrSdlError;