Struct glfw::Window

source ·
pub struct Window {
    pub is_shared: bool,
    pub glfw: Glfw,
    /* private fields */
}
Expand description

A struct that wraps a *GLFWwindow handle.

Fields§

§is_shared: bool§glfw: Glfw

Implementations§

source§

impl Window

source

pub fn get_proc_address(&mut self, procname: &str) -> GLProc

Returns the address of the specified client API or extension function if it is supported by the context associated with this Window. If this Window is not the current context, it will make it the current context.

Wrapper for glfwGetProcAddress.

source

pub fn create_shared( &self, width: u32, height: u32, title: &str, mode: WindowMode<'_> ) -> Option<(PWindow, GlfwReceiver<(f64, WindowEvent)>)>

Creates a new shared window.

Wrapper for glfwCreateWindow.

source

pub fn close(self)

Calling this method forces the destructor to be called, closing the window.

source

pub fn render_context(&mut self) -> PRenderContext

Returns a render context that can be shared between tasks, allowing for concurrent rendering.

source

pub fn should_close(&self) -> bool

Wrapper for glfwWindowShouldClose.

source

pub fn set_should_close(&mut self, value: bool)

Wrapper for glfwSetWindowShouldClose.

source

pub fn set_title(&mut self, title: &str)

Sets the title of the window.

Wrapper for glfwSetWindowTitle.

source

pub fn get_pos(&self) -> (i32, i32)

Wrapper for glfwGetWindowPos.

source

pub fn set_pos(&mut self, xpos: i32, ypos: i32)

Wrapper for glfwSetWindowPos.

source

pub fn get_size(&self) -> (i32, i32)

Wrapper for glfwGetWindowSize.

source

pub fn set_size(&mut self, width: i32, height: i32)

Wrapper for glfwSetWindowSize.

source

pub fn get_frame_size(&self) -> (i32, i32, i32, i32)

Wrapper for glfwGetWindowFrameSize

Returns (left, top, right, bottom) edge window frame sizes, in screen coordinates.

source

pub fn get_framebuffer_size(&self) -> (i32, i32)

Wrapper for glfwGetFramebufferSize.

source

pub fn set_aspect_ratio(&mut self, numer: u32, denum: u32)

Wrapper for glfwSetWindowAspectRatio.

source

pub fn set_size_limits( &mut self, minwidth: Option<u32>, minheight: Option<u32>, maxwidth: Option<u32>, maxheight: Option<u32> )

Wrapper for glfwSetWindowSizeLimits.

A value of None is equivalent to GLFW_DONT_CARE. If minwidth or minheight are None, no minimum size is enforced. If maxwidth or maxheight are None, no maximum size is enforced.

source

pub fn iconify(&mut self)

Wrapper for glfwIconifyWindow.

source

pub fn restore(&mut self)

Wrapper for glfwRestoreWindow.

source

pub fn maximize(&mut self)

Wrapper for glfwMaximizeWindow

source

pub fn show(&mut self)

Wrapper for glfwShowWindow.

source

pub fn hide(&mut self)

Wrapper for glfwHideWindow.

source

pub fn with_window_mode<T, F>(&self, f: F) -> T
where F: FnOnce(WindowMode<'_>) -> T,

Returns whether the window is fullscreen or windowed.

§Example
window.with_window_mode(|mode| {
    match mode {
        glfw::Windowed => println!("Windowed"),
        glfw::FullScreen(m) => println!("FullScreen({})", m.get_name()),
    }
});
source

pub fn set_monitor( &mut self, mode: WindowMode<'_>, xpos: i32, ypos: i32, width: u32, height: u32, refresh_rate: Option<u32> )

Wrapper for glfwSetWindowMonitor

source

pub fn focus(&mut self)

Wrapper for glfwFocusWindow

It is NOT recommended to use this function, as it steals focus from other applications and can be extremely disruptive to the user.

source

pub fn is_focused(&self) -> bool

Wrapper for glfwGetWindowAttrib called with FOCUSED.

source

pub fn is_iconified(&self) -> bool

Wrapper for glfwGetWindowAttrib called with ICONIFIED.

source

pub fn is_maximized(&self) -> bool

Wrapper for glfwGetWindowattrib called with MAXIMIZED.

source

pub fn get_client_api(&self) -> c_int

Wrapper for glfwGetWindowAttrib called with CLIENT_API.

source

pub fn get_context_version(&self) -> Version

Wrapper for glfwGetWindowAttrib called with CONTEXT_VERSION_MAJOR, CONTEXT_VERSION_MINOR and CONTEXT_REVISION.

§Returns

The client API version of the window’s context in a version struct.

source

pub fn get_context_robustness(&self) -> c_int

Wrapper for glfwGetWindowAttrib called with CONTEXT_ROBUSTNESS.

source

pub fn is_opengl_forward_compat(&self) -> bool

Wrapper for glfwGetWindowAttrib called with OPENGL_FORWARD_COMPAT.

source

pub fn is_opengl_debug_context(&self) -> bool

Wrapper for glfwGetWindowAttrib called with OPENGL_DEBUG_CONTEXT.

source

pub fn get_opengl_profile(&self) -> c_int

Wrapper for glfwGetWindowAttrib called with OPENGL_PROFILE.

source

pub fn is_resizable(&self) -> bool

Wrapper for glfwGetWindowAttrib called with RESIZABLE.

source

pub fn set_resizable(&mut self, resizable: bool)

Wrapper for glfwSetWindowAttrib called with RESIZABLE.

source

pub fn is_visible(&self) -> bool

Wrapper for glfwGetWindowAttrib called with VISIBLE.

source

pub fn is_decorated(&self) -> bool

Wrapper for glfwGetWindowAttrib called with DECORATED.

source

pub fn set_decorated(&mut self, decorated: bool)

Wrapper for glfwSetWindowAttrib called with DECORATED.

source

pub fn is_auto_iconify(&self) -> bool

Wrapper for glfwGetWindowAttrib called with AUTO_ICONIFY.

source

pub fn set_auto_iconify(&mut self, auto_iconify: bool)

Wrapper for glfwSetWindowAttrib called with AUTO_ICONIFY.

source

pub fn is_floating(&self) -> bool

Wrapper for glfwGetWindowAttrib called with FLOATING.

source

pub fn set_floating(&mut self, floating: bool)

Wrapper for glfwSetWindowAttrib called with FLOATING.

source

pub fn is_framebuffer_transparent(&self) -> bool

Wrapper for glfwGetWindowAttrib called with TRANSPARENT_FRAMEBUFFER.

source

pub fn is_focus_on_show(&self) -> bool

Wrapper for glfwGetWindowAttrib called with FOCUS_ON_SHOW.

source

pub fn set_focus_on_show(&mut self, focus_on_show: bool)

Wrapper for glfwSetWindowAttrib called with FOCUS_ON_SHOW.

source

pub fn is_hovered(&self) -> bool

Wrapper for glfwGetWindowAttrib called with HOVERED.

source

pub fn set_pos_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, i32, i32) + 'static,

Wrapper for glfwSetWindowPosCallback.

source

pub fn unset_pos_callback(&mut self)

Wrapper for glfwSetWindowPosCallback.

source

pub fn set_pos_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowPosCallback.

source

pub fn set_size_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, i32, i32) + 'static,

Wrapper for glfwSetWindowSizeCallback.

source

pub fn unset_size_callback(&mut self)

Wrapper for glfwSetWindowSizeCallback.

source

pub fn set_size_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowSizeCallback.

source

pub fn set_close_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window) + 'static,

Wrapper for glfwSetWindowCloseCallback.

source

pub fn unset_close_callback(&mut self)

Wrapper for glfwSetWindowCloseCallback.

source

pub fn set_close_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowCloseCallback.

source

pub fn set_refresh_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window) + 'static,

Wrapper for glfwSetWindowRefreshCallback.

source

pub fn unset_refresh_callback(&mut self)

Wrapper for glfwSetWindowRefreshCallback.

source

pub fn set_refresh_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowRefreshCallback.

source

pub fn set_focus_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, bool) + 'static,

Wrapper for glfwSetWindowFocusCallback.

source

pub fn unset_focus_callback(&mut self)

Wrapper for glfwSetWindowFocusCallback.

source

pub fn set_focus_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowFocusCallback.

source

pub fn set_iconify_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, bool) + 'static,

Wrapper for glfwSetWindowIconifyCallback.

source

pub fn unset_iconify_callback(&mut self)

Wrapper for glfwSetWindowIconifyCallback.

source

pub fn set_iconify_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowIconifyCallback.

source

pub fn set_framebuffer_size_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, i32, i32) + 'static,

Wrapper for glfwSetFramebufferSizeCallback.

source

pub fn unset_framebuffer_size_callback(&mut self)

Wrapper for glfwSetFramebufferSizeCallback.

source

pub fn set_framebuffer_size_polling(&mut self, should_poll: bool)

Wrapper for glfwSetFramebufferSizeCallback.

source

pub fn set_key_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, Key, Scancode, Action, Modifiers) + 'static,

Wrapper for glfwSetKeyCallback.

source

pub fn unset_key_callback(&mut self)

Wrapper for glfwSetKeyCallback.

source

pub fn set_key_polling(&mut self, should_poll: bool)

Wrapper for glfwSetKeyCallback.

source

pub fn set_char_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, char) + 'static,

Wrapper for glfwSetCharCallback.

source

pub fn unset_char_callback(&mut self)

Wrapper for glfwSetCharCallback.

source

pub fn set_char_polling(&mut self, should_poll: bool)

Wrapper for glfwSetCharCallback.

source

pub fn set_char_mods_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, char, Modifiers) + 'static,

Wrapper for glfwSetCharModsCallback.

source

pub fn unset_char_mods_callback(&mut self)

Wrapper for glfwSetCharModsCallback.

source

pub fn set_char_mods_polling(&mut self, should_poll: bool)

Wrapper for glfwSetCharModsCallback.

source

pub fn set_mouse_button_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, MouseButton, Action, Modifiers) + 'static,

Wrapper for glfwSetMouseButtonCallback.

source

pub fn unset_mouse_button_callback(&mut self)

Wrapper for glfwSetMouseButtonCallback.

source

pub fn set_mouse_button_polling(&mut self, should_poll: bool)

Wrapper for glfwSetMouseButtonCallback.

source

pub fn set_cursor_pos_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, f64, f64) + 'static,

Wrapper for glfwSetCursorPosCallback.

source

pub fn unset_cursor_pos_callback(&mut self)

Wrapper for glfwSetCursorPosCallback.

source

pub fn set_cursor_pos_polling(&mut self, should_poll: bool)

Wrapper for glfwSetCursorPosCallback.

source

pub fn set_cursor_enter_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, bool) + 'static,

Wrapper for glfwSetCursorEnterCallback.

source

pub fn unset_cursor_enter_callback(&mut self)

Wrapper for glfwSetCursorEnterCallback.

source

pub fn set_cursor_enter_polling(&mut self, should_poll: bool)

Wrapper for glfwSetCursorEnterCallback.

source

pub fn set_scroll_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, f64, f64) + 'static,

Wrapper for glfwSetScrollCallback.

source

pub fn unset_scroll_callback(&mut self)

Wrapper for glfwSetScrollCallback.

source

pub fn set_scroll_polling(&mut self, should_poll: bool)

Wrapper for glfwSetScrollCallback.

source

pub fn set_drag_and_drop_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, Vec<PathBuf>) + 'static,

Wrapper for glfwSetDropCallback.

source

pub fn unset_drag_and_drop_callback(&mut self)

Wrapper for glfwSetDropCallback.

source

pub fn set_drag_and_drop_polling(&mut self, should_poll: bool)

Wrapper for glfwSetDropCallback.

source

pub fn set_maximize_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, bool) + 'static,

Wrapper for glfwSetWindowMaximizeCallback.

source

pub fn unset_maximize_callback(&mut self)

Wrapper for glfwSetWindowMaximizeCallback.

source

pub fn set_maximize_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowMaximizeCallback.

source

pub fn set_content_scale_callback<T>(&mut self, callback: T)
where T: FnMut(&mut Window, f32, f32) + 'static,

Wrapper for glfwSetWindowContentScaleCallback.

source

pub fn unset_content_scale_callback(&mut self)

Wrapper for glfwSetWindowContentScaleCallback.

source

pub fn set_content_scale_polling(&mut self, should_poll: bool)

Wrapper for glfwSetWindowContentScaleCallback.

source

pub fn set_all_polling(&mut self, should_poll: bool)

Starts or stops polling for all available events

source

pub fn get_cursor_mode(&self) -> CursorMode

Wrapper for glfwGetInputMode called with CURSOR.

source

pub fn set_cursor_mode(&mut self, mode: CursorMode)

Wrapper for glfwSetInputMode called with CURSOR.

source

pub fn set_cursor(&mut self, cursor: Option<Cursor>) -> Option<Cursor>

Wrapper for glfwSetCursor using Cursor

The window will take ownership of the cursor, and will not Drop it until it is replaced or the window itself is destroyed.

Returns the previously set Cursor or None if no cursor was set.

source

pub fn set_icon_from_pixels(&mut self, images: Vec<PixelImage>)

Sets the window icon via glfwSetWindowIcon from a set a set of vectors containing pixels in RGBA format (one pixel per 32-bit integer)

source

pub fn has_sticky_keys(&self) -> bool

Wrapper for glfwGetInputMode called with STICKY_KEYS.

source

pub fn set_sticky_keys(&mut self, value: bool)

Wrapper for glfwSetInputMode called with STICKY_KEYS.

source

pub fn has_sticky_mouse_buttons(&self) -> bool

Wrapper for glfwGetInputMode called with STICKY_MOUSE_BUTTONS.

source

pub fn set_sticky_mouse_buttons(&mut self, value: bool)

Wrapper for glfwSetInputMode called with STICKY_MOUSE_BUTTONS.

source

pub fn does_store_lock_key_mods(&self) -> bool

Wrapper for glfwGetInputMode called with LOCK_KEY_MODS

source

pub fn set_store_lock_key_mods(&mut self, value: bool)

Wrapper for glfwSetInputMode called with LOCK_KEY_MODS

source

pub fn uses_raw_mouse_motion(&self) -> bool

Wrapper for glfwGetInputMode called with RAW_MOUSE_MOTION

source

pub fn set_raw_mouse_motion(&mut self, value: bool)

Wrapper for glfwSetInputMode called with RAW_MOUSE_MOTION

source

pub fn get_key(&self, key: Key) -> Action

Wrapper for glfwGetKey.

source

pub fn get_mouse_button(&self, button: MouseButton) -> Action

Wrapper for glfwGetMouseButton.

source

pub fn get_cursor_pos(&self) -> (f64, f64)

Wrapper for glfwGetCursorPos.

source

pub fn set_cursor_pos(&mut self, xpos: f64, ypos: f64)

Wrapper for glfwSetCursorPos.

source

pub fn set_clipboard_string(&mut self, string: &str)

Wrapper for glfwGetClipboardString.

source

pub fn get_clipboard_string(&self) -> Option<String>

Wrapper for glfwGetClipboardString.

source

pub fn get_opacity(&self) -> f32

Wrapper for glfwGetWindowOpacity.

source

pub fn set_opacity(&mut self, opacity: f32)

Wrapper for glfwSetWindowOpacity.

source

pub fn request_attention(&mut self)

Wrapper for glfwRequestWindowAttention.

source

pub fn get_content_scale(&self) -> (f32, f32)

Wrapper for glfwGetWindowContentScale.

source

pub fn get_x11_window(&self) -> *mut c_void

Wrapper for glfwGetX11Window

source

pub fn get_glx_context(&self) -> *mut c_void

Wrapper for glfwGetGLXContext

Trait Implementations§

source§

impl Context for Window

source§

fn window_ptr(&self) -> *mut GLFWwindow

Returns the pointer to the underlying GLFWwindow.
source§

fn window_id(&self) -> WindowId

Returns the unique identifier for this window.
source§

fn swap_buffers(&mut self)

Swaps the front and back buffers of the window. If the swap interval is greater than zero, the GPU driver waits the specified number of screen updates before swapping the buffers. Read more
source§

fn is_current(&self) -> bool

Returns true if the window is the current context.
source§

fn make_current(&mut self)

Wrapper for glfwMakeContextCurrent
source§

fn should_close(&self) -> bool

Wrapper for glfwWindowShouldClose.
source§

fn set_should_close(&mut self, value: bool)

Wrapper for glfwSetWindowShouldClose.
source§

fn post_empty_event(&self)

Wrapper for glfwPostEmptyEvent.
source§

impl Debug for Window

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Window

source§

fn drop(&mut self)

Closes the window and performs the necessary cleanups. This will block until all associated RenderContexts were also dropped, and emit a debug! message to that effect.

Wrapper for glfwDestroyWindow.

source§

impl HasDisplayHandle for Window

source§

fn display_handle(&self) -> Result<DisplayHandle<'_>, HandleError>

Get a handle to the display controller of the windowing system.
source§

impl HasWindowHandle for Window

source§

fn window_handle(&self) -> Result<WindowHandle<'_>, HandleError>

Get a handle to the window.

Auto Trait Implementations§

§

impl RefUnwindSafe for Window

§

impl !Send for Window

§

impl !Sync for Window

§

impl Unpin for Window

§

impl UnwindSafe for Window

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> HasRawDisplayHandle for T
where T: HasDisplayHandle + ?Sized,

source§

fn raw_display_handle(&self) -> Result<RawDisplayHandle, HandleError>

👎Deprecated: Use HasDisplayHandle instead
source§

impl<T> HasRawWindowHandle for T
where T: HasWindowHandle + ?Sized,

source§

fn raw_window_handle(&self) -> Result<RawWindowHandle, HandleError>

👎Deprecated: Use HasWindowHandle instead
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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.