summaryrefslogtreecommitdiff
path: root/opengl-bindings/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2026-05-28 19:56:43 +0200
committerHampusM <hampus@hampusmat.com>2026-05-28 19:56:43 +0200
commit038aead236e77f41e6d229510a5e25741a6815c6 (patch)
treefe50c328568f656e3528bef56b550b6b836c7102 /opengl-bindings/src/lib.rs
parentaba4f418af2e514c78fe06a1c98949670eaeacd9 (diff)
refactor(opengl-bindings): remove CurrentContextWithFns
Diffstat (limited to 'opengl-bindings/src/lib.rs')
-rw-r--r--opengl-bindings/src/lib.rs29
1 files changed, 9 insertions, 20 deletions
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<sys::Gl>,
}
-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<SurfaceType: SurfaceTypeTrait>(
&self,
surface: &Surface<SurfaceType>,
- ) -> Result<CurrentContextWithFns<'_>, 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
}
}