diff --git a/CHANGELOG.md b/CHANGELOG.md index bed8265ab8..7cd9cfb059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,7 @@ # Unreleased - Added `PossiblyCurrentContext::make_not_current_in_place(&self)` for when `Send` capability of `NotCurrentContext` is not required. -- Added `NotCurrentContext::make_current_surfaceless(self)` and - `PossiblyCurrentContext::make_current_surfaceless(&self)` in the `Cgl` - implementation to allow the use of surfaceless contexts on MacOS. -- Added `NotCurrentContext::make_current_surfaceless(self)` and - `PossiblyCurrentContext::make_current_surfaceless(&self)` in the `Glx` - implementation to allow the use of surfaceless contexts with GLX. -- Added `NotCurrentContext::make_current_surfaceless(self)` and - `PossiblyCurrentContext::make_current_surfaceless(&self)` in the `Wgl` - implementation to allow the use of surfaceless contexts with WGL. - +- **Breaking:** Added `make_current_surfaceless(self)` for `{Possibly,Not}CurrentGlContext`. # Version 0.32.1 diff --git a/glutin/src/api/cgl/context.rs b/glutin/src/api/cgl/context.rs index 8450286709..2d6f3516e7 100644 --- a/glutin/src/api/cgl/context.rs +++ b/glutin/src/api/cgl/context.rs @@ -74,13 +74,6 @@ pub struct NotCurrentContext { } impl NotCurrentContext { - /// Make a [`Self::PossiblyCurrentContext`] indicating that the context - /// could be current on the thread. - pub fn make_current_surfaceless(self) -> Result { - self.inner.make_current_surfaceless()?; - Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) - } - fn new(inner: ContextInner) -> Self { Self { inner, _nosync: PhantomData } } @@ -109,6 +102,11 @@ impl NotCurrentGlContext for NotCurrentContext { ) -> Result { Err(self.inner.make_current_draw_read(surface_draw, surface_read).into()) } + + fn make_current_surfaceless(self) -> Result { + self.inner.make_current_surfaceless()?; + Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) + } } impl GlContext for NotCurrentContext { @@ -150,13 +148,6 @@ pub struct PossiblyCurrentContext { _nosendsync: PhantomData<*mut ()>, } -impl PossiblyCurrentContext { - /// Make this context current on the calling thread. - pub fn make_current_surfaceless(&self) -> Result<()> { - self.inner.make_current_surfaceless() - } -} - impl PossiblyCurrentGlContext for PossiblyCurrentContext { type NotCurrentContext = NotCurrentContext; type Surface = Surface; @@ -189,6 +180,10 @@ impl PossiblyCurrentGlContext for PossiblyCurrentContext { ) -> Result<()> { Err(self.inner.make_current_draw_read(surface_draw, surface_read).into()) } + + fn make_current_surfaceless(&self) -> Result<()> { + self.inner.make_current_surfaceless() + } } impl GlContext for PossiblyCurrentContext { diff --git a/glutin/src/api/egl/context.rs b/glutin/src/api/egl/context.rs index d8827d9329..b58b1cbf9e 100644 --- a/glutin/src/api/egl/context.rs +++ b/glutin/src/api/egl/context.rs @@ -172,13 +172,6 @@ pub struct NotCurrentContext { } impl NotCurrentContext { - /// Make a [`Self::PossiblyCurrentContext`] indicating that the context - /// could be current on the thread. - pub fn make_current_surfaceless(self) -> Result { - self.inner.make_current_surfaceless()?; - Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) - } - fn new(inner: ContextInner) -> Self { Self { inner } } @@ -208,6 +201,11 @@ impl NotCurrentGlContext for NotCurrentContext { self.inner.make_current_draw_read(surface_draw, surface_read)?; Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) } + + fn make_current_surfaceless(self) -> Result { + self.inner.make_current_surfaceless()?; + Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) + } } impl GlContext for NotCurrentContext { @@ -247,13 +245,6 @@ pub struct PossiblyCurrentContext { _nosendsync: PhantomData, } -impl PossiblyCurrentContext { - /// Make this context current on the calling thread. - pub fn make_current_surfaceless(&self) -> Result<()> { - self.inner.make_current_surfaceless() - } -} - impl PossiblyCurrentGlContext for PossiblyCurrentContext { type NotCurrentContext = NotCurrentContext; type Surface = Surface; @@ -285,6 +276,10 @@ impl PossiblyCurrentGlContext for PossiblyCurrentContext { ) -> Result<()> { self.inner.make_current_draw_read(surface_draw, surface_read) } + + fn make_current_surfaceless(&self) -> Result<()> { + self.inner.make_current_surfaceless() + } } impl GlContext for PossiblyCurrentContext { diff --git a/glutin/src/api/glx/context.rs b/glutin/src/api/glx/context.rs index 3c6df4f6c8..12189a57a2 100644 --- a/glutin/src/api/glx/context.rs +++ b/glutin/src/api/glx/context.rs @@ -241,15 +241,6 @@ pub struct NotCurrentContext { } impl NotCurrentContext { - /// Make a [`Self::PossiblyCurrentContext`] indicating that the context - /// could be current on the thread. - /// - /// Requires the GLX_ARB_create_context extension and OpenGL 3.0 or greater. - pub fn make_current_surfaceless(self) -> Result { - self.inner.make_current_surfaceless()?; - Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) - } - fn new(inner: ContextInner) -> Self { Self { inner } } @@ -279,6 +270,11 @@ impl NotCurrentGlContext for NotCurrentContext { self.inner.make_current_draw_read(surface_draw, surface_read)?; Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) } + + fn make_current_surfaceless(self) -> Result { + self.inner.make_current_surfaceless()?; + Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) + } } impl GlContext for NotCurrentContext { @@ -319,15 +315,6 @@ pub struct PossiblyCurrentContext { _nosendsync: PhantomData, } -impl PossiblyCurrentContext { - /// Make this context current on the calling thread. - /// - /// Requires the GLX_ARB_create_context extension and OpenGL 3.0 or greater. - pub fn make_current_surfaceless(&self) -> Result<()> { - self.inner.make_current_surfaceless() - } -} - impl PossiblyCurrentGlContext for PossiblyCurrentContext { type NotCurrentContext = NotCurrentContext; type Surface = Surface; @@ -356,6 +343,10 @@ impl PossiblyCurrentGlContext for PossiblyCurrentContext { ) -> Result<()> { self.inner.make_current_draw_read(surface_draw, surface_read) } + + fn make_current_surfaceless(&self) -> Result<()> { + self.inner.make_current_surfaceless() + } } impl GlContext for PossiblyCurrentContext { diff --git a/glutin/src/api/wgl/context.rs b/glutin/src/api/wgl/context.rs index e676ba7914..67d44b2524 100644 --- a/glutin/src/api/wgl/context.rs +++ b/glutin/src/api/wgl/context.rs @@ -232,15 +232,6 @@ impl NotCurrentContext { fn new(inner: ContextInner) -> Self { Self { inner } } - - /// Make a [`Self::PossiblyCurrentContext`] indicating that the context - /// could be current on the thread. - /// - /// Requires the WGL_ARB_create_context extension and OpenGL 3.0 or greater. - pub fn make_current_surfaceless(self) -> Result { - self.inner.make_current_surfaceless()?; - Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) - } } impl NotCurrentGlContext for NotCurrentContext { @@ -266,6 +257,11 @@ impl NotCurrentGlContext for NotCurrentContext { ) -> Result { Err(self.inner.make_current_draw_read(surface_draw, surface_read).into()) } + + fn make_current_surfaceless(self) -> Result { + self.inner.make_current_surfaceless()?; + Ok(PossiblyCurrentContext { inner: self.inner, _nosendsync: PhantomData }) + } } impl GlContext for NotCurrentContext { @@ -304,15 +300,6 @@ pub struct PossiblyCurrentContext { _nosendsync: PhantomData, } -impl PossiblyCurrentContext { - /// Make this context current on the calling thread. - /// - /// Requires the WGL_ARB_create_context extension and OpenGL 3.0 or greater. - pub fn make_current_surfaceless(&self) -> Result<()> { - self.inner.make_current_surfaceless() - } -} - impl PossiblyCurrentGlContext for PossiblyCurrentContext { type NotCurrentContext = NotCurrentContext; type Surface = Surface; @@ -349,6 +336,10 @@ impl PossiblyCurrentGlContext for PossiblyCurrentContext { ) -> Result<()> { Err(self.inner.make_current_draw_read(surface_draw, surface_read).into()) } + + fn make_current_surfaceless(&self) -> Result<()> { + self.inner.make_current_surfaceless() + } } impl Sealed for PossiblyCurrentContext {} diff --git a/glutin/src/context.rs b/glutin/src/context.rs index 1c1c22b04c..1abacbe33c 100644 --- a/glutin/src/context.rs +++ b/glutin/src/context.rs @@ -49,9 +49,9 @@ pub trait NotCurrentGlContext: Sealed { /// guaranteed to be current. fn treat_as_possibly_current(self) -> Self::PossiblyCurrentContext; - /// Make [`Self::Surface`] on the calling thread producing the + /// Make [`Self::Surface`] current on the calling thread producing the /// [`Self::PossiblyCurrentContext`] indicating that the context could - /// be current on the thread. + /// be current on the calling thread. /// /// # Platform specific /// @@ -67,7 +67,7 @@ pub trait NotCurrentGlContext: Sealed { /// The same as [`Self::make_current`], but provides a way to set read and /// draw surfaces. /// - /// # Api-specific: + /// # Api specific /// /// - **WGL/CGL:** not supported. fn make_current_draw_read( @@ -75,6 +75,16 @@ pub trait NotCurrentGlContext: Sealed { surface_draw: &Self::Surface, surface_read: &Self::Surface, ) -> Result; + + /// Make context current on the calling thread without a default + /// framebuffer producing the [`Self::PossiblyCurrentContext`] indicating + /// that the context could be current on the calling thread. + /// + /// # Api specific + /// + /// - **WGL/GLX:** requires OpenGL 3.0 or greater context and + /// ARB_create_context extensions. + fn make_current_surfaceless(self) -> Result; } /// A trait to group common context operations. @@ -109,10 +119,10 @@ pub trait PossiblyCurrentGlContext: Sealed { /// - **macOS: this will block if your main thread is blocked.** fn make_current(&self, surface: &Self::Surface) -> Result<()>; - /// The same as [`Self::make_current`] but provides a way to set read and + /// The same as [`Self::make_current`], but provides a way to set read and /// draw surfaces explicitly. /// - /// # Api-specific: + /// # Api specific /// /// - **CGL/WGL:** not supported. fn make_current_draw_read( @@ -120,6 +130,15 @@ pub trait PossiblyCurrentGlContext: Sealed { surface_draw: &Self::Surface, surface_read: &Self::Surface, ) -> Result<()>; + + /// Make context current on the calling thread without a default + /// framebuffer. + /// + /// # Api specific + /// + /// - **WGL/GLX:** requires OpenGL 3.0 or greater context and + /// ARB_create_context extensions. + fn make_current_surfaceless(&self) -> Result<()>; } /// A trait that provides raw context. @@ -156,7 +175,7 @@ impl ContextAttributesBuilder { /// To get sharing working it's recommended to use the same [`Config`] when /// creating contexts that are going to be shared. /// - /// # Platform-specific + /// # Platform specific /// /// - **Wayland:** both contexts must use the same Wayland connection. /// @@ -190,7 +209,7 @@ impl ContextAttributesBuilder { /// /// By default the profile is unspecified. /// - /// # Api-specific + /// # Api specific /// /// - **macOS:** not supported, the latest is picked automatically. pub fn with_profile(mut self, profile: GlProfile) -> Self { @@ -210,7 +229,7 @@ impl ContextAttributesBuilder { /// /// The `raw_window_handle` isn't required and here for WGL compatibility. /// - /// # Api-specific + /// # Api specific /// /// - **WGL:** you **must** pass a `raw_window_handle` if you plan to use /// this context with that window. @@ -338,7 +357,7 @@ pub enum ReleaseBehavior { /// Doesn't do anything. Most notably doesn't flush. Not supported by all /// drivers. /// - /// # Api-specific + /// # Api specific /// /// - **macOS:** not supported, [`Self::Flush`] is always used. None, @@ -391,6 +410,12 @@ impl NotCurrentGlContext for NotCurrentContext { gl_api_dispatch!(self; Self(context) => context.treat_as_possibly_current(); as PossiblyCurrentContext) } + fn make_current_surfaceless(self) -> Result { + Ok( + gl_api_dispatch!(self; Self(context) => context.make_current_surfaceless()?; as PossiblyCurrentContext), + ) + } + fn make_current( self, surface: &Self::Surface, @@ -522,6 +547,10 @@ impl PossiblyCurrentGlContext for PossiblyCurrentContext { ) } + fn make_current_surfaceless(&self) -> Result<()> { + gl_api_dispatch!(self; Self(context) => context.make_current_surfaceless()) + } + fn make_not_current_in_place(&self) -> Result<()> { Ok(gl_api_dispatch!(self; Self(context) => context.make_not_current_in_place()?)) }