[][src]Struct glutin::ContextWrapper

pub struct ContextWrapper<T: ContextCurrentState, W> { /* fields omitted */ }

A context which has an underlying window, which may or may not be stored separately.

If the window is stored separately, it is a RawContext<T>. Otherwise, it is a WindowedContext<T>.

Implementations

impl<T: ContextCurrentState> ContextWrapper<T, Window>[src]

pub fn window(&self) -> &Window[src]

Borrow the inner W.

pub unsafe fn split(self) -> (RawContext<T>, Window)[src]

Split the Window apart from the OpenGL Context. Should only be used when intending to transfer the RawContext<T> to another thread.

Unsaftey:

impl<W> ContextWrapper<PossiblyCurrent, W>[src]

pub fn swap_buffers(&self) -> Result<(), ContextError>[src]

Swaps the buffers in case of double or triple buffering.

You should call this function every time you have finished rendering, or the image may not be displayed on the screen.

Warning: if you enabled vsync, this function will block until the next time the screen is refreshed. However drivers can choose to override your vsync settings, which means that you can't know in advance whether swap_buffers will block or not.

pub fn swap_buffers_with_damage(
    &self,
    rects: &[Rect]
) -> Result<(), ContextError>
[src]

Swaps the buffers in case of double or triple buffering using specified damage rects.

You should call this function every time you have finished rendering, or the image may not be displayed on the screen.

Warning: if you enabled vsync, this function will block until the next time the screen is refreshed. However drivers can choose to override your vsync settings, which means that you can't know in advance whether swap_buffers will block or not.

pub fn swap_buffers_with_damage_supported(&self) -> bool[src]

Returns whether or not swap_buffer_with_damage is available. If this function returns false, any call to swap_buffers_with_damage will return an error.

pub fn get_pixel_format(&self) -> PixelFormat[src]

Returns the pixel format of the main framebuffer of the context.

pub fn resize(&self, size: PhysicalSize<u32>)[src]

Resize the context.

Some platforms (macOS, Wayland) require being manually updated when their window or surface is resized.

The easiest way of doing this is to take every Resized window event that is received and pass its PhysicalSize into this function.

impl<T: ContextCurrentState, W> ContextWrapper<T, W>[src]

pub fn context(&self) -> &Context<T>[src]

Borrow the inner GL Context.

pub unsafe fn make_current(
    self
) -> Result<ContextWrapper<PossiblyCurrent, W>, (Self, ContextError)>
[src]

Sets this context as the current context. The previously current context (if any) is no longer current.

A failed call to make_current might make this, or no context current. It could also keep the previous context current. What happens varies by platform and error.

To attempt to recover and get back into a know state, either:

  • attempt to use is_current to find the new current context; or
  • call make_not_current on both the previously current context and this context.

An higher level overview.

In OpenGl, only a single context can be current in a thread at a time. Making a new context current will make the old one not current. Contexts can only be sent to different threads if they are not current.

If you call make_current on some context, you should call treat_as_not_current as soon as possible on the previously current context.

If you wish to move a currently current context to a different thread, you should do one of two options:

If you are aware of what context you intend to make current next, it is preferable for performance reasons to call make_current on that context, then treat_as_not_current on this context.

If you are not aware of what context you intend to make current next, consider waiting until you do. If you need this context not current immediately (e.g. to transfer it to another thread), then call make_not_current on this context.

Please avoid calling make_not_current on one context only to call make_current on another context before and/or after. This hurts performance by requiring glutin to:

  • Check if this context is current; then
  • If it is, change the current context from this context to none; then
  • Change the current context from none to the new context.

Instead prefer the method we mentioned above with make_current and treat_as_not_current.

pub unsafe fn make_not_current(
    self
) -> Result<ContextWrapper<NotCurrent, W>, (Self, ContextError)>
[src]

If this context is current, makes this context not current. If this context is not current however, this function does nothing.

Please see make_current.

pub unsafe fn treat_as_not_current(self) -> ContextWrapper<NotCurrent, W>[src]

Treats this context as not current, even if it is current. We do no checks to confirm that this is actually case.

If unsure whether or not this context is current, please use make_not_current which will do nothing if this context is not current.

Please see make_current.

pub unsafe fn treat_as_current(self) -> ContextWrapper<PossiblyCurrent, W>[src]

Treats this context as current, even if it is not current. We do no checks to confirm that this is actually case.

This function should only be used if you intend to track context currency without the limited aid of glutin, and you wish to store all the Contexts as NotCurrent.

Please see make_current for the prefered method of handling context currency.

pub fn is_current(&self) -> bool[src]

Returns true if this context is the current one in this thread.

pub fn get_api(&self) -> Api[src]

Returns the OpenGL API being used.

impl<W> ContextWrapper<PossiblyCurrent, W>[src]

pub fn get_proc_address(&self, addr: &str) -> *const c_void[src]

Returns the address of an OpenGL function.

Methods from Deref<Target = Context<T>>

pub fn is_current(&self) -> bool[src]

pub fn get_api(&self) -> Api[src]

pub fn get_proc_address(&self, addr: &str) -> *const c_void[src]

Trait Implementations

impl<T: Debug + ContextCurrentState, W: Debug> Debug for ContextWrapper<T, W>[src]

impl<T: ContextCurrentState, W> Deref for ContextWrapper<T, W>[src]

type Target = Context<T>

The resulting type after dereferencing.

Auto Trait Implementations

impl<T, W> !RefUnwindSafe for ContextWrapper<T, W>

impl<T, W> Send for ContextWrapper<T, W> where
    T: Send,
    W: Send

impl<T, W> Sync for ContextWrapper<T, W> where
    T: Sync,
    W: Sync

impl<T, W> Unpin for ContextWrapper<T, W> where
    T: Unpin,
    W: Unpin

impl<T, W> !UnwindSafe for ContextWrapper<T, W>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.