Struct glutin::Context

source ·
pub struct Context { /* private fields */ }
Expand description

Represents an OpenGL context.

A Context is normally associated with a single Window, however Contexts can be shared between multiple windows or be headless.

Example

let cb = glutin::ContextBuilder::new()
    .with_vsync(true)
    .with_multisampling(8)
    .with_shared_lists(some_context.context());

Implementations§

source§

impl Context

source

pub fn new_headless( el: &EventsLoop, cb: ContextBuilder<'_>, dims: PhysicalSize ) -> Result<Self, CreationError>

Builds the given GL context.

One notable limitation of the Wayland backend when it comes to shared contexts is that both contexts must use the same events loop.

Errors can occur in two scenarios:

  • If the window could not be created (via permission denied, incompatible system, out of memory, etc.). This should be very rare.
  • If the OpenGL context could not be created. This generally happens because the underlying platform doesn’t support a requested feature.

Trait Implementations§

source§

impl ContextTrait for Context

source§

unsafe fn make_current(&self) -> Result<(), ContextError>

Sets the context as the current context.
source§

fn is_current(&self) -> bool

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

fn get_proc_address(&self, addr: &str) -> *const ()

Returns the address of an OpenGL function.
source§

fn get_api(&self) -> Api

Returns the OpenGL API being used.
source§

impl ContextTraitExt for Context

§

type Handle = RawHandle

Raw context handle.
source§

unsafe fn raw_handle(&self) -> Self::Handle

Returns the raw context handle.
source§

unsafe fn get_egl_display(&self) -> Option<*const c_void>

Returns a pointer to the EGLDisplay object of EGL that is used by this context. Read more
source§

impl RawContextExt for Context

source§

unsafe fn new_raw_context( hwnd: *mut c_void, cb: ContextBuilder<'_> ) -> Result<RawContext, CreationError>where Self: Sized,

Creates a raw context on the provided 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> SetParameter for T

§

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere T: Parameter<Self>,

Sets value as a parameter of self.
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.