Struct sdl2::video::Window
[−]
[src]
pub struct Window { /* fields omitted */ }
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>
Methods
impl Window
[src]
fn raw(&self) -> *mut SDL_Window
unsafe fn from_ll(subsystem: VideoSubsystem, raw: *mut SDL_Window) -> Window
unsafe fn from_ref(context: Rc<WindowContext>) -> Window
Create a new Window
without taking ownership of the WindowContext
fn subsystem(&self) -> &VideoSubsystem
fn into_canvas(self) -> CanvasBuilder
Initializes a new CanvasBuilder
; a convenience method that calls CanvasBuilder::new()
.
fn context(&self) -> Rc<WindowContext>
fn id(&self) -> u32
fn gl_create_context(&self) -> Result<GLContext, String>
fn gl_set_context_to_current(&self) -> Result<(), String>
Set the window's OpenGL context to the current context on the thread.
fn gl_make_current(&self, context: &GLContext) -> Result<(), String>
fn gl_swap_window(&self)
fn display_index(&self) -> Result<i32, String>
fn set_display_mode<D>(&mut self, display_mode: D) -> Result<(), String> where
D: Into<Option<DisplayMode>>,
D: Into<Option<DisplayMode>>,
fn display_mode(&self) -> Result<DisplayMode, String>
fn window_pixel_format(&self) -> PixelFormatEnum
fn window_flags(&self) -> u32
fn set_title(&mut self, title: &str) -> Result<(), NulError>
fn title(&self) -> &str
fn set_icon<S: AsRef<SurfaceRef>>(&mut self, icon: S)
fn set_position(&mut self, x: WindowPos, y: WindowPos)
fn position(&self) -> (i32, i32)
fn set_size(&mut self, width: u32, height: u32) -> Result<(), IntegerOrSdlError>
fn size(&self) -> (u32, u32)
fn drawable_size(&self) -> (u32, u32)
fn set_minimum_size(
&mut self,
width: u32,
height: u32
) -> Result<(), IntegerOrSdlError>
&mut self,
width: u32,
height: u32
) -> Result<(), IntegerOrSdlError>
fn minimum_size(&self) -> (u32, u32)
fn set_maximum_size(
&mut self,
width: u32,
height: u32
) -> Result<(), IntegerOrSdlError>
&mut self,
width: u32,
height: u32
) -> Result<(), IntegerOrSdlError>
fn maximum_size(&self) -> (u32, u32)
fn set_bordered(&mut self, bordered: bool)
fn show(&mut self)
fn hide(&mut self)
fn raise(&mut self)
fn maximize(&mut self)
fn minimize(&mut self)
fn restore(&mut self)
fn fullscreen_state(&self) -> FullscreenType
fn set_fullscreen(
&mut self,
fullscreen_type: FullscreenType
) -> Result<(), String>
&mut self,
fullscreen_type: FullscreenType
) -> Result<(), String>
fn surface<'a>(
&'a self,
_e: &'a EventPump
) -> Result<WindowSurfaceRef<'a>, String>
&'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 !
fn set_grab(&mut self, grabbed: bool)
fn grab(&self) -> bool
fn set_brightness(&mut self, brightness: f64) -> Result<(), String>
fn brightness(&self) -> f64
fn set_gamma_ramp<'a, 'b, 'c, R, G, B>(
&mut self,
red: R,
green: G,
blue: B
) -> Result<(), String> where
R: Into<Option<&'a [u16; 256]>>,
G: Into<Option<&'b [u16; 256]>>,
B: Into<Option<&'c [u16; 256]>>,
&mut self,
red: R,
green: G,
blue: B
) -> Result<(), String> where
R: Into<Option<&'a [u16; 256]>>,
G: Into<Option<&'b [u16; 256]>>,
B: Into<Option<&'c [u16; 256]>>,
fn gamma_ramp(&self) -> Result<(Vec<u16>, Vec<u16>, Vec<u16>), String>
Trait Implementations
impl From<WindowContext> for Window
[src]
fn from(context: WindowContext) -> Window
Performs the conversion.