Struct sdl2_window::Sdl2Window
source · [−]pub struct Sdl2Window {
pub window: Window,
pub context: GLContext,
pub sdl_context: Sdl,
pub video_subsystem: VideoSubsystem,
/* private fields */
}
Expand description
A window implemented by SDL2 back-end.
Fields
window: Window
SDL window handle.
context: GLContext
Allow dead code because this keeps track of the OpenGL context. Will be released on drop.
sdl_context: Sdl
SDL context.
video_subsystem: VideoSubsystem
Video subsystem.
Implementations
sourceimpl Sdl2Window
impl Sdl2Window
sourcepub fn new(settings: &WindowSettings) -> Result<Self, Box<dyn Error>>
pub fn new(settings: &WindowSettings) -> Result<Self, Box<dyn Error>>
Creates a new game window for SDL2. This will initialize SDL and the video subsystem.
You can retrieve both via the public fields on the Sdl2Window
struct.
sourcepub fn with_subsystem(
video_subsystem: VideoSubsystem,
settings: &WindowSettings
) -> Result<Self, Box<dyn Error>>
pub fn with_subsystem(
video_subsystem: VideoSubsystem,
settings: &WindowSettings
) -> Result<Self, Box<dyn Error>>
Creates a window with the supplied SDL Video subsystem.
sourcepub fn init_joysticks(&mut self) -> Result<u32, String>
pub fn init_joysticks(&mut self) -> Result<u32, String>
Initialize the joystick subsystem. Required before joystick input events will be returned. Returns the number available or error.
Trait Implementations
sourceimpl AdvancedWindow for Sdl2Window
impl AdvancedWindow for Sdl2Window
sourcefn get_automatic_close(&self) -> bool
fn get_automatic_close(&self) -> bool
Gets whether the window will automatically close when attempting to close it. Read more
sourcefn set_automatic_close(&mut self, value: bool)
fn set_automatic_close(&mut self, value: bool)
Sets whether the window will automatically close when attempting
to close it. If this is disabled, attempts to close the window
can be detected via an Input::Close(..)
event, and
Window::set_should_close()
can be called to actually close the window. Read more
sourcefn get_exit_on_esc(&self) -> bool
fn get_exit_on_esc(&self) -> bool
Gets whether to exit when pressing esc. Read more
sourcefn set_exit_on_esc(&mut self, value: bool)
fn set_exit_on_esc(&mut self, value: bool)
Sets whether to exit when pressing esc. Read more
sourcefn set_capture_cursor(&mut self, value: bool)
fn set_capture_cursor(&mut self, value: bool)
Sets whether to capture/grab the cursor. Read more
sourcefn get_position(&self) -> Option<Position>
fn get_position(&self) -> Option<Position>
Gets the position of window.
sourcefn set_position<P: Into<Position>>(&mut self, pos: P)
fn set_position<P: Into<Position>>(&mut self, pos: P)
Sets the position of window. Read more
sourcefn exit_on_esc(self, value: bool) -> Self
fn exit_on_esc(self, value: bool) -> Self
Sets whether to exit when pressing the Esc button. Read more
sourcefn automatic_close(self, value: bool) -> Self
fn automatic_close(self, value: bool) -> Self
Sets whether the window will automatically close when attempting
to close it. If this is disabled, attempts to close the window
can be detected via an Input::Close(..)
event, and
Window::set_should_close()
can be called to actually close the window. Read more
sourcefn capture_cursor(self, value: bool) -> Self
fn capture_cursor(self, value: bool) -> Self
Sets whether to capture/grab the cursor. Read more
sourceimpl BuildFromWindowSettings for Sdl2Window
impl BuildFromWindowSettings for Sdl2Window
sourcefn build_from_window_settings(
settings: &WindowSettings
) -> Result<Self, Box<dyn Error>>
fn build_from_window_settings(
settings: &WindowSettings
) -> Result<Self, Box<dyn Error>>
Builds the window from a WindowSettings
object. Read more
sourceimpl Drop for Sdl2Window
impl Drop for Sdl2Window
sourceimpl OpenGLWindow for Sdl2Window
impl OpenGLWindow for Sdl2Window
sourcefn get_proc_address(&mut self, proc_name: &str) -> ProcAddress
fn get_proc_address(&mut self, proc_name: &str) -> ProcAddress
Returns the address of the specified OpenGL function if it exists. Read more
sourcefn is_current(&self) -> bool
fn is_current(&self) -> bool
Returns true if this window’s gl context is the current gl context.
sourcefn make_current(&mut self)
fn make_current(&mut self)
Make the window’s gl context the current gl context.
sourceimpl Window for Sdl2Window
impl Window for Sdl2Window
sourcefn should_close(&self) -> bool
fn should_close(&self) -> bool
Returns true if the window should close.
sourcefn set_should_close(&mut self, value: bool)
fn set_should_close(&mut self, value: bool)
Tells the window to close or stay open.
sourcefn swap_buffers(&mut self)
fn swap_buffers(&mut self)
Swaps render buffers. Read more
sourcefn wait_event(&mut self) -> Event
fn wait_event(&mut self) -> Event
Wait indefinitely for an input event to be available from the window.
sourcefn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>
fn wait_event_timeout(&mut self, timeout: Duration) -> Option<Event>
Wait for an input event to be available from the window or for the specified timeout to be reached. Read more
sourcefn poll_event(&mut self) -> Option<Event>
fn poll_event(&mut self) -> Option<Event>
Polls an input event from the window. Read more
Auto Trait Implementations
impl RefUnwindSafe for Sdl2Window
impl !Send for Sdl2Window
impl !Sync for Sdl2Window
impl Unpin for Sdl2Window
impl UnwindSafe for Sdl2Window
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more