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.
Example
let context = glutin::ContextBuilder::new()
.with_vsync(true)
.with_multisampling(8)
.with_shared_lists(some_gl_window.context());Implementations§
source§impl Context
impl Context
sourcepub fn new(
el: &EventsLoop,
context_builder: ContextBuilder<'_>,
shareable_with_windowed_contexts: bool
) -> Result<Self, CreationError>
pub fn new( el: &EventsLoop, context_builder: ContextBuilder<'_>, shareable_with_windowed_contexts: bool ) -> Result<Self, CreationError>
Builds the given GL context
Contexts made with the shareable_with_windowed_contexts flag set to
true can be shared with:
- contexts made with that flag set to
true; and - contexts made when creating a
GlWindow.
If the flag is set to false on the other hand, the context should only
be shared with other contexts made with the flag set to false.
Some platforms might not implement contexts which aren’t shareable with windowed contexts. If so, those platforms will fallback to making a contexts which are shareable with windowed contexts.
You are not guaranteed to receive an error if you share a context with an other context which you’re not permitted to share it with, as according to:
- the restrictions stated by us above; and
- the restrictions imposed on you by the platform your application runs
on. (Please refer to
README-SHARING.md)
Failing to follow all the context sharing restrictions imposed on you may result in unsafe behavior.
This safe variant of new_shared will panic if you try to share it with
an existing context.
Error should be very rare and only occur in case of permission denied, incompatible system, out of memory, etc.
Builds the given GL context
Contexts made with the shareable_with_windowed_contexts flag set to
true can be shared with:
- contexts made with that flag set to
true; and - contexts made when creating a
GlWindow.
If the flag is set to false on the other hand, the context should only
be shared with other contexts made with the flag set to false.
Some platforms might not implement contexts which aren’t shareable with windowed contexts. If so, those platforms will fallback to making a contexts which are shareable with windowed contexts.
You are not guaranteed to receive an error if you share a context with an other context which you’re not permitted to share it with, as according to:
- the restrictions stated by us above; and
- the restrictions imposed on you by the platform your application runs
on. (Please refer to
README-SHARING.md)
Failing to follow all the context sharing restrictions imposed on you may result in unsafe behavior.
Error should be very rare and only occur in case of permission denied, incompatible system, out of memory, etc.