Skip to content

Commit

Permalink
Pass gl to ContextDescriptor::from_egl_context
Browse files Browse the repository at this point in the history
  • Loading branch information
sagudev committed Feb 9, 2025
1 parent f36b577 commit a65b884
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 20 deletions.
6 changes: 1 addition & 5 deletions src/platform/egl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,7 @@ impl Device {
/// Returns the descriptor that this context was created with.
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor {
unsafe {
ContextDescriptor::from_egl_context(
context::get_proc_address,
self.egl_display,
context.egl_context,
)
ContextDescriptor::from_egl_context(&context.gl, self.egl_display, context.egl_context)
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/platform/generic/egl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,20 +382,16 @@ impl ContextDescriptor {
})
}

pub(crate) unsafe fn from_egl_context<F>(
get_proc_address: F,
pub(crate) unsafe fn from_egl_context(
gl: &Gl,
egl_display: EGLDisplay,
egl_context: EGLContext,
) -> ContextDescriptor
where
F: FnMut(&str) -> *const c_void,
{
) -> ContextDescriptor {
let egl_config_id = get_context_attr(egl_display, egl_context, egl::CONFIG_ID as EGLint);

EGL_FUNCTIONS.with(|egl| {
let _guard = CurrentContextGuard::new();
egl.MakeCurrent(egl_display, egl::NO_SURFACE, egl::NO_SURFACE, egl_context);
let gl = unsafe { Gl::from_loader_function(get_proc_address) };
let gl_version = GLVersion::current(&gl);
let compatibility_profile = context::current_context_uses_compatibility_profile(&gl);

Expand Down
2 changes: 1 addition & 1 deletion src/platform/unix/generic/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl Device {
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor {
unsafe {
ContextDescriptor::from_egl_context(
context::get_proc_address,
&context.1,
self.native_connection.egl_display,
context.0.egl_context,
)
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unix/wayland/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Device {
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor {
unsafe {
ContextDescriptor::from_egl_context(
context::get_proc_address,
&context.1,
self.native_connection.egl_display,
context.0.egl_context,
)
Expand Down
2 changes: 1 addition & 1 deletion src/platform/unix/x11/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Device {
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor {
unsafe {
ContextDescriptor::from_egl_context(
context::get_proc_address,
&context.1,
self.native_connection.egl_display,
context.0.egl_context,
)
Expand Down
6 changes: 1 addition & 5 deletions src/platform/windows/angle/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,7 @@ impl Device {
/// Returns the descriptor that this context was created with.
pub fn context_descriptor(&self, context: &Context) -> ContextDescriptor {
unsafe {
ContextDescriptor::from_egl_context(
context::get_proc_address,
self.egl_display,
context.egl_context,
)
ContextDescriptor::from_egl_context(&context.gl, self.egl_display, context.egl_context)
}
}

Expand Down

0 comments on commit a65b884

Please sign in to comment.