logo

Struct rg3d::ContextWrapper[][src]

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

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

Borrow the inner W.

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

Unsaftey:

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.

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.

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.

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

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.

Borrow the inner GL Context.

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.

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.

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.

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.

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

Returns the OpenGL API being used.

Returns the address of an OpenGL function.

Methods from Deref<Target = Context<T>>

Trait Implementations

Formats the value using the given formatter. Read more

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Casts self to a &dyn Any

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.