pub struct Window { /* private fields */ }
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§
source§impl Window
impl Window
pub fn raw(&self) -> *mut SDL_Window
pub unsafe fn from_ll(subsystem: VideoSubsystem, raw: *mut SDL_Window) -> Window
sourcepub unsafe fn from_ref(context: Rc<WindowContext>) -> Window
pub unsafe fn from_ref(context: Rc<WindowContext>) -> Window
Create a new Window
without taking ownership of the WindowContext
pub fn subsystem(&self) -> &VideoSubsystem
sourcepub fn into_canvas(self) -> CanvasBuilder
pub fn into_canvas(self) -> CanvasBuilder
Initializes a new CanvasBuilder
; a convenience method that calls CanvasBuilder::new()
.
pub fn context(&self) -> Rc<WindowContext>
pub fn id(&self) -> u32
pub fn gl_create_context(&self) -> Result<GLContext, String>
sourcepub fn gl_set_context_to_current(&self) -> Result<(), String>
pub fn gl_set_context_to_current(&self) -> Result<(), String>
Set the window’s OpenGL context to the current context on the thread.
pub fn gl_make_current(&self, context: &GLContext) -> Result<(), String>
pub fn gl_swap_window(&self)
sourcepub fn vulkan_instance_extensions(&self) -> Result<Vec<&'static str>, String>
pub fn vulkan_instance_extensions(&self) -> Result<Vec<&'static str>, String>
Get the names of the Vulkan instance extensions needed to create a surface with vulkan_create_surface
.
sourcepub fn vulkan_create_surface(
&self,
instance: VkInstance,
) -> Result<VkSurfaceKHR, String>
pub fn vulkan_create_surface( &self, instance: VkInstance, ) -> Result<VkSurfaceKHR, String>
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.
pub fn display_index(&self) -> Result<i32, String>
pub fn set_display_mode<D>(&mut self, display_mode: D) -> Result<(), String>
pub fn display_mode(&self) -> Result<DisplayMode, String>
pub fn window_pixel_format(&self) -> PixelFormatEnum
pub fn window_flags(&self) -> u32
pub fn set_title(&mut self, title: &str) -> Result<(), NulError>
pub fn title(&self) -> &str
pub fn set_icon<S: AsRef<SurfaceRef>>(&mut self, icon: S)
pub fn set_position(&mut self, x: WindowPos, y: WindowPos)
pub fn position(&self) -> (i32, i32)
sourcepub fn border_size(&self) -> Result<(u16, u16, u16, u16), String>
pub fn border_size(&self) -> Result<(u16, u16, u16, u16), String>
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.
pub fn set_size( &mut self, width: u32, height: u32, ) -> Result<(), IntegerOrSdlError>
pub fn size(&self) -> (u32, u32)
pub fn drawable_size(&self) -> (u32, u32)
pub fn vulkan_drawable_size(&self) -> (u32, u32)
pub fn set_minimum_size( &mut self, width: u32, height: u32, ) -> Result<(), IntegerOrSdlError>
pub fn minimum_size(&self) -> (u32, u32)
pub fn set_maximum_size( &mut self, width: u32, height: u32, ) -> Result<(), IntegerOrSdlError>
pub fn maximum_size(&self) -> (u32, u32)
pub fn set_bordered(&mut self, bordered: bool)
pub fn show(&mut self)
pub fn hide(&mut self)
pub fn raise(&mut self)
pub fn maximize(&mut self)
pub fn minimize(&mut self)
pub fn restore(&mut self)
pub fn fullscreen_state(&self) -> FullscreenType
pub fn set_fullscreen( &mut self, fullscreen_type: FullscreenType, ) -> Result<(), String>
sourcepub fn surface<'a>(
&'a self,
_e: &'a EventPump,
) -> Result<WindowSurfaceRef<'a>, String>
pub fn surface<'a>( &'a self, _e: &'a EventPump, ) -> Result<WindowSurfaceRef<'a>, String>
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 !