Struct glfw_window::GlfwWindow

source ·
pub struct GlfwWindow {
    pub window: PWindow,
    pub glfw: Glfw,
    pub joystick_deadzone: f64,
    /* private fields */
}
Expand description

Contains stuff for game window.

Fields§

§window: PWindow

The window.

§glfw: Glfw

GLFW context.

§joystick_deadzone: f64

ignore controller axis inputs below this threshold

Implementations§

source§

impl GlfwWindow

source

pub fn from_pieces( win: PWindow, glfw: Glfw, events: Receiver<(f64, WindowEvent)>, exit_on_esc: bool ) -> GlfwWindow

Create a new game window from an existing GLFW window.

Examples found in repository?
examples/window_from_pieces.rs (line 15)
8
9
10
11
12
13
14
15
16
fn main() {
    let mut glfw = glfw::init_no_callbacks().unwrap();
    let (mut glfw_window, glfw_events) = glfw.create_window(640, 480, "GLFW Window", glfw::WindowMode::Windowed).unwrap();
    
    glfw_window.set_all_polling(true);
    glfw_window.make_current();
    
    let _: GlfwWindow = GlfwWindow::from_pieces(glfw_window, glfw, glfw_events, true);
}
source

pub fn new(settings: &WindowSettings) -> Result<GlfwWindow, Box<dyn Error>>

Creates a new game window for GLFW.

Examples found in repository?
examples/window_settings.rs (lines 8-12)
7
8
9
10
11
12
13
fn main() {
    let _ = GlfwWindow::new(
        &WindowSettings::new("GLFW Window", (640, 480))
            .fullscreen(false)
            .vsync(true) // etc
    ).unwrap();
}
More examples
Hide additional examples
examples/window_opengl.rs (lines 11-16)
10
11
12
13
14
15
16
17
fn main() {
    let _ = GlfwWindow::new(
        &WindowSettings::new("GLFW Window", (640, 480))
            .fullscreen(false)
            .vsync(true)
            .graphics_api(OpenGL::V2_1) // etc
    ).unwrap();
}

Trait Implementations§

source§

impl AdvancedWindow for GlfwWindow

source§

fn get_title(&self) -> String

Gets a copy of the title of the window.
source§

fn set_title(&mut self, value: String)

Sets the title of the window.
source§

fn get_automatic_close(&self) -> bool

Gets whether the window will automatically close when attempting to close it. Read more
source§

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
source§

fn get_exit_on_esc(&self) -> bool

Gets whether to exit when pressing esc. Read more
source§

fn set_exit_on_esc(&mut self, value: bool)

Sets whether to exit when pressing esc. Read more
source§

fn set_capture_cursor(&mut self, value: bool)

Sets whether to capture/grab the cursor. Read more
source§

fn show(&mut self)

Shows the window. Read more
source§

fn hide(&mut self)

Hides the window. Read more
source§

fn get_position(&self) -> Option<Position>

Gets the position of window.
source§

fn set_position<P: Into<Position>>(&mut self, pos: P)

Sets the position of window. Read more
source§

fn set_size<S: Into<Size>>(&mut self, size: S)

Sets the window size. Read more
source§

fn title(self, value: String) -> Self

Sets title on window. Read more
source§

fn exit_on_esc(self, value: bool) -> Self

Sets whether to exit when pressing the Esc button. Read more
source§

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
source§

fn capture_cursor(self, value: bool) -> Self

Sets whether to capture/grab the cursor. Read more
source§

fn position<P>(self, val: P) -> Selfwhere P: Into<Position>,

Sets the position of window. Read more
source§

impl BuildFromWindowSettings for GlfwWindow

source§

fn build_from_window_settings( settings: &WindowSettings ) -> Result<GlfwWindow, Box<dyn Error>>

Builds the window from a WindowSettings object. Read more
source§

impl OpenGLWindow for GlfwWindow

source§

fn get_proc_address(&mut self, proc_name: &str) -> ProcAddress

Returns the address of the specified OpenGL function if it exists. Read more
source§

fn is_current(&self) -> bool

Returns true if this window’s gl context is the current gl context.
source§

fn make_current(&mut self)

Make the window’s gl context the current gl context.
source§

impl Window for GlfwWindow

source§

fn size(&self) -> Size

Gets the size of the window.
source§

fn draw_size(&self) -> Size

Gets the draw size of the window. Read more
source§

fn set_should_close(&mut self, value: bool)

Tells the window to close or stay open.
source§

fn should_close(&self) -> bool

Returns true if the window should close.
source§

fn swap_buffers(&mut self)

Swaps render buffers. Read more
source§

fn wait_event(&mut self) -> Event

Wait indefinitely for an input event to be available from the window.
source§

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
source§

fn poll_event(&mut self) -> Option<Event>

Polls an input event from the window. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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, U> Into<U> for Twhere 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 Twhere 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 Twhere 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.