pub struct Context { /* private fields */ }
Expand description
Represents an OpenGL context.
A Context
is normally associated with a single Window, however Context
s
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
impl Context
sourcepub fn new_headless(
el: &EventsLoop,
cb: ContextBuilder<'_>,
dims: PhysicalSize
) -> Result<Self, CreationError>
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
impl ContextTrait for Context
source§unsafe fn make_current(&self) -> Result<(), ContextError>
unsafe fn make_current(&self) -> Result<(), ContextError>
Sets the context as the current context.
source§fn is_current(&self) -> bool
fn is_current(&self) -> bool
Returns true if this context is the current one in this thread.
source§impl ContextTraitExt for Context
impl ContextTraitExt for Context
source§impl OsMesaContextExt for Context
impl OsMesaContextExt for Context
source§fn new_osmesa(
cb: ContextBuilder<'_>,
dims: PhysicalSize
) -> Result<Self, CreationError>where
Self: Sized,
fn new_osmesa( cb: ContextBuilder<'_>, dims: PhysicalSize ) -> Result<Self, CreationError>where Self: Sized,
Builds the given OsMesa context.
Errors can occur if the OpenGL context could not be created. This generally happens because the underlying platform doesn’t support a requested feature.
source§impl RawContextExt for Context
impl RawContextExt for Context
source§unsafe fn new_raw_wayland_context(
display_ptr: *const wl_display,
surface: *mut c_void,
width: u32,
height: u32,
cb: ContextBuilder<'_>
) -> Result<RawContext, CreationError>where
Self: Sized,
unsafe fn new_raw_wayland_context( display_ptr: *const wl_display, surface: *mut c_void, width: u32, height: u32, cb: ContextBuilder<'_> ) -> Result<RawContext, CreationError>where Self: Sized,
Creates a raw context on the provided surface. Read more
source§unsafe fn new_raw_x11_context(
xconn: Arc<XConnection>,
xwin: c_ulong,
cb: ContextBuilder<'_>
) -> Result<RawContext, CreationError>where
Self: Sized,
unsafe fn new_raw_x11_context( xconn: Arc<XConnection>, xwin: c_ulong, cb: ContextBuilder<'_> ) -> Result<RawContext, CreationError>where Self: Sized,
Creates a raw context on the provided window. Read more
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more