Struct VideoSubsystem

Source
pub struct VideoSubsystem { /* private fields */ }

Implementations§

Source§

impl VideoSubsystem

Source§

impl VideoSubsystem

Source§

impl VideoSubsystem

Source

pub fn sdl(&self) -> Sdl

Obtain an SDL context.

Source§

impl VideoSubsystem

Source

pub fn gl_attr(&self) -> GLAttr<'_>

Obtains access to the OpenGL window attributes.

Source§

impl VideoSubsystem

Source

pub fn window(&self, title: &str, width: u32, height: u32) -> WindowBuilder

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

Source

pub fn current_video_driver(&self) -> &'static str

Get the name of the currently initialized video driver.

Source

pub fn num_video_displays(&self) -> Result<i32, String>

Get the number of available video displays.

Source

pub fn display_name(&self, display_index: i32) -> Result<String, String>

Get the name of the display at the index display_name.

Will return an error if the index is out of bounds or if SDL experienced a failure; inspect the returned string for further info.

Source

pub fn display_bounds(&self, display_index: i32) -> Result<Rect, String>

Get the desktop area represented by a display.

The primary display (display_index = 0) is always located at 0,0.

Source

pub fn display_usable_bounds(&self, display_index: i32) -> Result<Rect, String>

Get the usable desktop area represented by a display.

The primary display (display_index = 0) is always located at 0,0.

This is the same area as display_bounds reports, but with portions reserved by the system removed. For example, on Apple’s macOS, this subtracts the area occupied by the menu bar and dock. Setting a window to be fullscreen generally bypasses these unusable areas, so these are good guidelines for the maximum space available to a non-fullscreen window.

Source

pub fn num_display_modes(&self, display_index: i32) -> Result<i32, String>

Get the number of available display modes.

Source

pub fn display_mode( &self, display_index: i32, mode_index: i32, ) -> Result<DisplayMode, String>

Get information about a specific display mode.

The display modes are sorted in this priority:

  • width -> largest to smallest
  • height -> largest to smallest
  • bits per pixel -> more colors to fewer colors
  • packed pixel layout -> largest to smallest
  • refresh rate -> highest to lowest
Source

pub fn desktop_display_mode( &self, display_index: i32, ) -> Result<DisplayMode, String>

Get information about the desktop’s display mode.

There’s a difference between this function and current_display_mode when SDL runs fullscreen and has changed the resolution. In that case this function will return the previous native display mode, and not the current display mode.

Source

pub fn current_display_mode( &self, display_index: i32, ) -> Result<DisplayMode, String>

Get information about the current display mode.

There’s a difference between this function and desktop_display_mode when SDL runs fullscreen and has changed the resolution. In that case this function will return the current display mode, and not the previous native display mode.

Source

pub fn closest_display_mode( &self, display_index: i32, mode: &DisplayMode, ) -> Result<DisplayMode, String>

Get the closest match to the requested display mode.

The available display modes are scanned and the closest mode matching the requested mode is returned. The mode format and refresh rate default to the desktop mode if they are set to 0.

The modes are scanned with size being first priority, format being second priority, and finally checking the refresh rate. If all the available modes are too small, then error is returned.

Source

pub fn display_dpi(&self, display_index: i32) -> Result<(f32, f32, f32), String>

Return a triplet (ddpi, hdpi, vdpi) containing the diagonal, horizontal and vertical dots/pixels-per-inch of a display

Source

pub fn display_orientation(&self, display_index: i32) -> Orientation

Return orientation of a display or Unknown if orientation could not be determined.

Source

pub fn is_screen_saver_enabled(&self) -> bool

Check whether the screensaver is currently enabled.

Source

pub fn enable_screen_saver(&self)

Allow the screen to be blanked by a screen saver.

Source

pub fn disable_screen_saver(&self)

Prevent the screen from being blanked by a screen saver.

Source

pub fn gl_load_library_default(&self) -> Result<(), String>

Loads the default OpenGL library.

This should be done after initializing the video driver, but before creating any OpenGL windows. If no OpenGL library is loaded, the default library will be loaded upon creation of the first OpenGL window.

If a different library is already loaded, this function will return an error.

Source

pub fn gl_load_library<P: AsRef<Path>>(&self, path: P) -> Result<(), String>

Loads the OpenGL library using a platform-dependent OpenGL library name (usually a file path).

This should be done after initializing the video driver, but before creating any OpenGL windows. If no OpenGL library is loaded, the default library will be loaded upon creation of the first OpenGL window.

If a different library is already loaded, this function will return an error.

Source

pub fn gl_unload_library(&self)

Unloads the current OpenGL library.

To completely unload the library, this should be called for every successful load of the OpenGL library.

Source

pub fn gl_get_proc_address(&self, procname: &str) -> *const ()

Gets the pointer to the named OpenGL function.

This is useful for OpenGL wrappers such as gl-rs.

Source

pub fn gl_extension_supported(&self, extension: &str) -> bool

Check if an OpenGL extension is supported for the current context.

This function operates on the current GL context; you must have created a context, and it must be current before calling this function. Do not assume that all contexts you create will have the same set of extensions available, or that recreating an existing context will offer the same extensions again. While it’s probably not a massive overhead, this function is not an O(1) operation. Check the extensions you care about after creating the GL context and save that information somewhere instead of calling the function every time you need to know.

Source

pub fn gl_get_current_window_id(&self) -> Result<u32, String>

Get the currently active OpenGL window.

Source

pub fn gl_release_current_context(&self) -> Result<(), String>

Releases the thread’s current OpenGL context, i.e. sets the current OpenGL context to nothing.

Source

pub fn gl_set_swap_interval<S: Into<SwapInterval>>( &self, interval: S, ) -> Result<(), String>

Set the swap interval for the current OpenGL context.

Source

pub fn gl_get_swap_interval(&self) -> SwapInterval

Source

pub fn vulkan_load_library_default(&self) -> Result<(), String>

Loads the default Vulkan library.

This should be done after initializing the video driver, but before creating any Vulkan windows. If no Vulkan library is loaded, the default library will be loaded upon creation of the first Vulkan window.

If a different library is already loaded, this function will return an error.

Source

pub fn vulkan_load_library<P: AsRef<Path>>(&self, path: P) -> Result<(), String>

Loads the Vulkan library using a platform-dependent Vulkan library name (usually a file path).

This should be done after initializing the video driver, but before creating any Vulkan windows. If no Vulkan library is loaded, the default library will be loaded upon creation of the first Vulkan window.

If a different library is already loaded, this function will return an error.

Source

pub fn vulkan_unload_library(&self)

Unloads the current Vulkan library.

To completely unload the library, this should be called for every successful load of the Vulkan library.

Source

pub fn vulkan_get_proc_address_function(&self) -> Result<*const (), String>

Gets the pointer to the vkGetInstanceProcAddr Vulkan function. This function can be called to retrieve the address of other Vulkan functions.

Trait Implementations§

Source§

impl Clone for VideoSubsystem

Source§

fn clone(&self) -> VideoSubsystem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VideoSubsystem

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.