Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polish glutin upgrade with glutin-winit crate #2526

Merged
merged 14 commits into from
Feb 8, 2023
Merged

polish glutin upgrade with glutin-winit crate #2526

merged 14 commits into from
Feb 8, 2023

Conversation

coderedart
Copy link
Contributor

  1. Cleaned up all the platform specific code by replacing it with glutin-winit helper crate.
  2. refactored the glutin backend to be more android friendly.

TODO:

  1. once winit 0.28 is released, we can add an example for eframe + android using android-activity = "0.4" and maybe some instructions for eframe-template on how to build

@coderedart
Copy link
Contributor Author

I think this is ready for review.

the PR is just mostly polishing the glutin upgrade by using glutin_winit helper crate and adding some logging to help with debugging glutin issues. In particular, egui glow using shader lang version constant will cause a seg fault if context comes from Microsoft S/W renderer with gl 1.1 context. this happens if user doesn't have proper drivers installed (apparently the case in virtual machines and remote desktop) for their GPU.

there could be some improvement using #2541 in future, where we just run the whole glutin window context creation function with preferEgl instead of FallbackEgl. I want to delay this as it might cause some weird bugs due to interaction of both egl/native displays, as glutin doesn't support destroying/cleaning up these resources yet.

@emilk
Copy link
Owner

emilk commented Jan 23, 2023

What is the motivation behind this PR? It adds a lot of code (and a dependency), so what problems is it solving? What features is it adding?

@coderedart
Copy link
Contributor Author

  1. push the context creation responsibility to glutin-winit, which needed some ugly platform gated code before. the crate is also maintained within the glutin repo. was recommended by one of the glutin devs during the first PR Glutin Upgrade  #2187 (comment)

It basically hides stuff like x11_visual and DisplayApiPreference, so you don't have platform specific code

  1. Some users have problems if we use Egl API first. so, changed the preference from PreferEgl to FallbackEgl. according to glutin devs, this was the behavior in older versions and the more reliable one. Fallback on GLX when EGL initialization fails #2541 (comment)

  2. refactor the code to match wgpu backend and be android friendly. mainly, separating context creation (once at startup) from window/surface creation (multiple times over the lifecycle of app). makes it seem like a lot of code, but its just existing code moved around for this. android support meant not always having a winit Window and i didn't want to deal with that complexity in the first PR, only focusing on desktop.

  3. add a bunch of logging because debugging opengl issues is hard. we had 2 issues about problems on virtual machines, where eframe might segfault for querying SHADER_LANGUAGE_VERSION (doesn't exist in opengl 1.1). logs will now immediately make this obvious. Can't run any of the examples in Windows, error "swap contol extrensions are not supported" #2545 failed to create glutin window surface #2520

@coderedart
Copy link
Contributor Author

Is there still some problem with merging this? The merge conflicts seem to be growing and dealing with git scares me.

If you don't want to merge this, then this can be closed in favor of #2541 .

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, looks good!

Sorry for the slowness

@coderedart
Copy link
Contributor Author

In epi integration, window_builder fn was changed to build_window. but glutin requires window_builder (because it decides when to actually build the window). so, i split build_window fn into window_builder and build_window functions.

https://github.com/coderedart/egui/blob/glutin_winit/crates/eframe/src/native/epi_integration.rs#L163

@coderedart
Copy link
Contributor Author

nice. this is done. is it okay to bump glow to 0.12 in a new pr?

@emilk emilk merged commit be9b5a3 into emilk:master Feb 8, 2023
@emilk
Copy link
Owner

emilk commented Feb 8, 2023

yes, go for it!

@emilk
Copy link
Owner

emilk commented Feb 8, 2023

Actually, I went ahead myself: #2695

@emilk emilk mentioned this pull request Feb 8, 2023
@coderedart coderedart deleted the glutin_winit branch February 9, 2023 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants