Add text in main doc page

This commit is contained in:
Cobrand
2017-11-12 23:25:49 +00:00
parent d6c51bb5f5
commit 86fc6fbddc
2 changed files with 51 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
//!
//! This crate was mainly generated by [`bindgen`](https://crates.io/crates/bindgen). It should be enough in most cases,
//! but if you ever find discrepancies between what bindgen generated and your OS, you can always
//! [generate your own `sdl2-sys`](https://github.com/rust-sdl2/rust-sdl2#generating-sdl2-sys-with-bindgen).
//!
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]

View File

@@ -1,3 +1,48 @@
//! # Getting started
//!
//! ```rust
//! use sdl2::pixels::Color;
//! use sdl2::event::Event;
//! use sdl2::keyboard::Keycode;
//! use std::time::Duration;
//!
//! pub fn main() {
//! let sdl_context = sdl2::init().unwrap();
//! let video_subsystem = sdl_context.video().unwrap();
//!
//! let window = video_subsystem.window("rust-sdl2 demo", 800, 600)
//! .position_centered()
//! .build()
//! .unwrap();
//!
//! let mut canvas = window.into_canvas().build().unwrap();
//!
//! canvas.set_draw_color(Color::RGB(0, 255, 255));
//! canvas.clear();
//! canvas.present();
//! let mut event_pump = sdl_context.event_pump().unwrap();
//! let mut i = 0;
//! 'running: loop {
//! i = (i + 1) % 255;
//! canvas.set_draw_color(Color::RGB(i, 64, 255 - i))
//! canvas.clear();
//! for event in event_pump.poll_iter() {
//! match event {
//! Event::Quit {..} |
//! Event::KeyDown { keycode: Some(Keycode::Escape), .. } => {
//! break 'running
//! },
//! _ => {}
//! }
//! }
//! // The rest of the game loop goes here...
//!
//! canvas.present();
//! ::std::thread::sleep(Duration::new(0, 1_000_000_000u32 / 60));
//! }
//! }
//! ```
#![crate_name = "sdl2"]
#![crate_type = "lib"]