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 locale;
78pub mod log;
79pub mod messagebox;
80pub mod mouse;
81pub mod pixels;
82pub mod rect;
83pub mod render;
84pub mod rwops;
85mod sdl;
86#[cfg(feature = "hidapi")]
87pub mod sensor;
88pub mod surface;
89pub mod timer;
90pub mod touch;
91pub mod url;
92pub mod version;
93pub mod video;
94
95// modules
96#[cfg(feature = "gfx")]
97pub mod gfx;
98#[cfg(feature = "image")]
99pub mod image;
100#[cfg(feature = "mixer")]
101pub mod mixer;
102#[cfg(feature = "ttf")]
103pub mod ttf;
104
105mod common;
106// Export return types and such from the common module.
107pub use crate::common::IntegerOrSdlError;
108
109#[cfg(feature = "raw-window-handle")]
110pub mod raw_window_handle;