Struct Display

Source
pub struct Display(/* private fields */);
Expand description

A handle to the platform-specific display backend.

On X11, for instance, it wraps a connection to the X server.

Implementations§

Source§

impl<'dpy> Display

Source

pub fn open() -> Result<Self, Error>

Attempts to get one handle to the platform-specific display backend.

You should need only one.

Examples found in repository?
examples/window.rs (line 8)
7fn main() {
8    let display = Display::open().expect("Could not open display!");
9    let window = display.create_window(&Default::default()).expect("Couldn't create window!");
10    window.set_title("Three");
11    window.show();
12    sleep(Duration::from_secs(1));
13    window.set_title("Two");
14    sleep(Duration::from_secs(1));
15    window.set_title("One");
16    sleep(Duration::from_secs(1));
17}
Source

pub fn open_x11_display_name(name: Option<&CStr>) -> Result<Self, Error>

X11-only specialization of open() where you can specify the name given to XOpenDisplay().

Source

pub fn create_window( &'dpy self, settings: &Settings, ) -> Result<Window<'dpy>, Error>

Attempts to create a Window with the given settings.

Examples found in repository?
examples/window.rs (line 9)
7fn main() {
8    let display = Display::open().expect("Could not open display!");
9    let window = display.create_window(&Default::default()).expect("Couldn't create window!");
10    window.set_title("Three");
11    window.show();
12    sleep(Duration::from_secs(1));
13    window.set_title("Two");
14    sleep(Duration::from_secs(1));
15    window.set_title("One");
16    sleep(Duration::from_secs(1));
17}
Source

pub fn create_window_and_show( &'dpy self, settings: &Settings, ) -> Result<Window<'dpy>, Error>

Same as create_window(), but immediately shows the window afterwards if it succeeds.

Source

pub fn create_gl_context( &'dpy self, settings: &GLContextSettings<'_>, ) -> Result<GLContext<'dpy>, Error>

Attempts to create a backend-specific OpenGL context.

Source

pub fn create_software_gl_context( &'dpy self, settings: &GLContextSettings<'_>, ) -> Result<GLContext<'dpy>, Error>

Sames as create_gl_context(), but attempts to get a context that is not hardware-accelerated (on some platforms, this might try to load the Mesa driver). The use case for this is simple apps that don’t specifically need a lot of perf, and would rather prefer saving battery power.

This won’t attempt to fall back to the default implementation - in other words, this will succeed only if it is certain that there is a software implementation available AND a context could be created out of it.

Source

pub fn create_gl_context_from_lib<P: AsRef<Path>>( &'dpy self, _settings: &GLContextSettings<'_>, _path: P, ) -> Result<GLContext<'dpy>, Error>

Attempts to create an OpenGL context from a dynamically-loaded library.

Trait Implementations§

Source§

impl Debug for Display

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.