Skip to content

Instantly share code, notes, and snippets.

@tronical
Created October 20, 2023 08:22
Show Gist options
  • Save tronical/bee9dceccdad2b74da18f7bed7e00208 to your computer and use it in GitHub Desktop.
Save tronical/bee9dceccdad2b74da18f7bed7e00208 to your computer and use it in GitHub Desktop.
diff --git a/internal/renderers/skia/opengl_surface.rs b/internal/renderers/skia/opengl_surface.rs
index 9f861b171..3b2d2c08b 100644
--- a/internal/renderers/skia/opengl_surface.rs
+++ b/internal/renderers/skia/opengl_surface.rs
@@ -58,10 +58,32 @@ fn new(
}
};
+ let mut missing_functions: Vec<String> = Vec::new();
+
let gl_interface = skia_safe::gpu::gl::Interface::new_load_with_cstr(|name| {
- current_glutin_context.display().get_proc_address(name) as *const _
+ let result = current_glutin_context.display().get_proc_address(name);
+ if result.is_null() {
+ missing_functions.push(name.to_str().unwrap().to_string());
+ }
+ result as *const _
});
+ for f in missing_functions {
+ eprintln!("absent GL function pointer: {f}");
+ }
+
+ if gl_interface.is_none() {
+ return Err(format!("Skia GL interface could not be created.").into());
+ }
+
+ let gl_interface = gl_interface.unwrap();
+
+ if !gl_interface.validate() {
+ return Err(format!("Skia GL interface validation failed.").into());
+ }
+
+
+
let mut gr_context =
skia_safe::gpu::DirectContext::new_gl(gl_interface, None).ok_or_else(|| {
format!("Skia Renderer: Internal Error: Could not create Skia OpenGL interface")
@@ -216,7 +238,7 @@ fn init_glutin(
} else if #[cfg(not(target_family = "windows"))] {
let prefs = [glutin::display::DisplayApiPreference::Egl];
} else {
- let prefs = [glutin::display::DisplayApiPreference::EglThenWgl(Some(_window_handle.raw_window_handle()))];
+ let prefs = [glutin::display::DisplayApiPreference::WglThenEgl(Some(_window_handle.raw_window_handle()))];
}
}
@@ -266,7 +288,7 @@ fn init_glutin(
let gles_context_attributes = ContextAttributesBuilder::new()
.with_context_api(ContextApi::Gles(Some(glutin::context::Version {
- major: 2,
+ major: 3,
minor: 0,
})))
.build(Some(_window_handle.raw_window_handle()));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment