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
51pub extern crate libc;
52
53#[macro_use]
54extern crate lazy_static;
55
56#[macro_use]
57extern crate bitflags;
58pub extern crate sdl2_sys as sys;
59
60#[cfg(feature = "gfx")]
61extern crate c_vec;
62
63pub use crate::sdl::*;
64
65pub mod clipboard;
66pub mod cpuinfo;
67#[macro_use]
68mod macros;
69pub mod audio;
70pub mod controller;
71pub mod event;
72pub mod filesystem;
73pub mod haptic;
74pub mod hint;
75pub mod joystick;
76pub mod keyboard;
77pub mod log;
78pub mod messagebox;
79pub mod mouse;
80pub mod pixels;
81pub mod rect;
82pub mod render;
83pub mod rwops;
84mod sdl;
85#[cfg(feature = "hidapi")]
86pub mod sensor;
87pub mod surface;
88pub mod timer;
89pub mod touch;
90pub mod url;
91pub mod version;
92pub mod video;
93
94// modules
95#[cfg(feature = "gfx")]
96pub mod gfx;
97#[cfg(feature = "image")]
98pub mod image;
99#[cfg(feature = "mixer")]
100pub mod mixer;
101#[cfg(feature = "ttf")]
102pub mod ttf;
103
104mod common;
105// Export return types and such from the common module.
106pub use crate::common::IntegerOrSdlError;
107
108#[cfg(feature = "raw-window-handle")]
109pub mod raw_window_handle;