Struct sdl2::video::Window [] [src]

pub struct Window {
    // some fields omitted
}

Methods

impl Window

fn raw(&self) -> *mut SDL_Window

unsafe fn from_ll(subsystem: VideoSubsystem, raw: *mut SDL_Window) -> Window

fn subsystem(&self) -> &VideoSubsystem

fn renderer(self) -> RendererBuilder

Initializes a new RendererBuilder; a convenience method that calls RendererBuilder::new().

fn properties<'b>(&'b mut self, _e: &'b EventPump) -> WindowProperties<'b>

Accesses the Window properties, such as the position, size and title of a Window.

In order to access a Window's properties, it must be guaranteed that the event loop is not running. This is why a reference to the application's SDL context is required (a shared Sdl reference is only obtainable if the event loop is not running). The event loop could otherwise mutate a Window's properties without your consent!

Example

let sdl_context = sdl2::init().unwrap();
let video_subsystem = sdl_context.video().unwrap();
let mut window = video_subsystem.window("My SDL window", 800, 600).build().unwrap();
let mut event_pump = sdl_context.event_pump().unwrap();

loop {
    let mut pos = None;

    for event in event_pump.poll_iter() {
        use sdl2::event::Event;
        match event {
            Event::MouseMotion { x, y, .. } => { pos = Some((x, y)); },
            _ => ()
        }
    }

    if let Some((x, y)) = pos {
        // Set the window title
        window.properties(&event_pump).set_title(&format!("{}, {}", x, y));
    }
}

fn properties_getters(&self) -> WindowPropertiesGetters

Accesses the read-only Window properties.

fn get_id(&self) -> u32

fn gl_create_context(&self) -> SdlResult<GLContext>

fn gl_set_context_to_current(&self) -> SdlResult<()>

Set the window's OpenGL context to the current context on the thread.

fn gl_make_current(&self, context: &GLContext) -> SdlResult<()>

fn gl_swap_window(&self)

Trait Implementations

impl Drop for Window

fn drop(&mut self)