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

pub struct Window { /* fields omitted */ }
Expand description

Represents the “shell” of a Window.

You can set get and set many of the SDL_Window properties (i.e., border, size, PixelFormat, etc)

However, you cannot directly access the pixels of the Window. It needs to be converted to a Canvas to access the rendering functions.

Note: If a Window goes out of scope but it cloned its context, then the SDL_Window will not be destroyed until there are no more references to the WindowContext. This may happen when a TextureCreator<Window> outlives the Canvas<Window>

Implementations

Create a new Window without taking ownership of the WindowContext

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

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

Get the names of the Vulkan instance extensions needed to create a surface with vulkan_create_surface.

Create a Vulkan rendering surface for a window.

The VkInstance must be created using a prior call to the vkCreateInstance function in the Vulkan library.

Use this function to set the icon for a window.

Example:
// requires "--features 'image'"
use sdl2::surface::Surface;

let window_icon = Surface::from_file("/path/to/icon.png")?;
window.set_icon(window_icon);

Use this function to get the size of a window’s borders (decorations) around the client area.

Remarks

This function is only supported on X11, otherwise an error is returned.

Returns a WindowSurfaceRef, which can be used like a regular Surface. This is an alternative way to the Renderer (Canvas) way to modify pixels directly in the Window.

For this to happen, simply create a WindowSurfaceRef via this method, use the underlying Surface however you like, and when the changes of the Surface must be applied to the screen, call update_window if you intend to keep using the WindowSurfaceRef afterwards, or finish if you don’t intend to use it afterwards.

The Renderer way is of course much more flexible and recommended; even though you only want to support Software Rendering (which is what using Surface is), you can still create a Renderer which renders in a Software-based manner, so try to rely on a Renderer as much as possible !

Set the transparency of the window. The given value will be clamped internally between 0.0 (fully transparent), and 1.0 (fully opaque).

This method returns an error if opacity isn’t supported by the current platform.

Returns the transparency of the window, as a value between 0.0 (fully transparent), and 1.0 (fully opaque).

If opacity isn’t supported by the current platform, this method returns Ok(1.0) instead of an error.

Trait Implementations

Performs the conversion.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.