From 038aead236e77f41e6d229510a5e25741a6815c6 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 28 May 2026 19:56:43 +0200 Subject: refactor(opengl-bindings): remove CurrentContextWithFns --- opengl-bindings/src/lib.rs | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) (limited to 'opengl-bindings/src/lib.rs') diff --git a/opengl-bindings/src/lib.rs b/opengl-bindings/src/lib.rs index cfdfa35..e4ae27d 100644 --- a/opengl-bindings/src/lib.rs +++ b/opengl-bindings/src/lib.rs @@ -16,13 +16,13 @@ pub mod shader; pub mod texture; pub mod vertex_array; -pub struct ContextWithFns +pub struct MaybeCurrentContextWithFns { context: PossiblyCurrentContext, fns: Box, } -impl ContextWithFns +impl MaybeCurrentContextWithFns { /// Returns a new `ContextWithFns`. /// @@ -51,14 +51,15 @@ impl ContextWithFns Ok(Self { context, fns: Box::new(gl) }) } - /// Attempts to make this context current. + /// Attempts to make this context & the specified surface current in the current + /// thread. /// /// # Errors /// Returns `Err` if making this context current fails. pub fn make_current( &self, surface: &Surface, - ) -> Result, MakeContextCurrentError> + ) -> Result<(), MakeContextCurrentError> { if !self.context.is_current() || !surface.is_current(&self.context) { self.context @@ -66,7 +67,7 @@ impl ContextWithFns .map_err(MakeContextCurrentError)?; } - Ok(CurrentContextWithFns { ctx: self }) + Ok(()) } #[must_use] @@ -75,24 +76,12 @@ impl ContextWithFns &self.context } - #[must_use] - pub fn context_mut(&mut self) -> &mut PossiblyCurrentContext - { - &mut self.context - } -} - -pub struct CurrentContextWithFns<'ctx> -{ - ctx: &'ctx ContextWithFns, -} - -impl CurrentContextWithFns<'_> -{ #[inline] pub(crate) fn fns(&self) -> &sys::Gl { - &self.ctx.fns + debug_assert!(self.context.is_current()); + + &self.fns } } -- cgit v1.2.3-18-g5258