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

Update pure_glow example to glutin 0.30 #2393

Open
Boscop opened this issue Dec 5, 2022 · 3 comments
Open

Update pure_glow example to glutin 0.30 #2393

Boscop opened this issue Dec 5, 2022 · 3 comments

Comments

@Boscop
Copy link

Boscop commented Dec 5, 2022

A lot has changed in glutin 0.30, it would be nice if the pure_glow example could be updated to glutin 0.30 :)

I had some code that was based on the pure_glow example before, now I'm updating it to glutin 0.30, but I'm not sure if I'm doing everything correctly with the new ways of doing things.
You can find my code here: rust-windowing/glutin#1445 (comment)

I would appreciate if you can let me know if it's correct. The pure_glow example could be updated similarly.

@coderedart
Copy link
Contributor

coderedart commented Dec 5, 2022

you are doing everything correctly afaict. glutin upgrade PR avoided touching too much code because if there's any unforeseen issues, it would be easier to rollback.

I am still unfamiliar with the latest glutin, but i will try answering some questions. could be wrong though as i have not tested them. asking on winit matrix server might be more helpful.

How can I ensure I get the latest opengl version at runtime?
Should I use .with_context_api(ContextApi::OpenGl(None)) or .with_context_api(ContextApi::OpenGl(Some(Version::new(4, 6))))?

I think you just require the latest version that you want. and if context creation fails, you just retry in a loop reducing the version until you create a context successfully

// version = [ (4, 6), (4, 3), (3, 3)] and so on
let mut gl_context = None;
for (major, minor) in versions {
  let attrs = ContextAttributesBuilder::new().with_context_api(ContextApi::OpenGl(Some(Version { major, minor}))).build(None);
  if let Ok(ctx) gl_display.create_context(&gl_config, &context_attributes) {
    gl_context = Some(ctx);
    break;
  }
}
let gl_context = gl_context.expect("could not find suitable context);

If I don't need to support Android, is it ok that I create the window (and call make_current) before the loop?

yep. it is easier that way.

Is my code equivalent to my previous code in all aspects? I couldn't find any equivalent for ContextBuilder::with_srgb(true)

with EGL atleast, you would use https://docs.rs/glutin/latest/glutin/surface/struct.SurfaceAttributesBuilder.html#method.with_srgb
As GlConfig actually has https://docs.rs/glutin/latest/aarch64-linux-android/glutin/config/trait.GlConfig.html#tymethod.srgb_capable fn, I think there should be a ConfigTemplateBuilder fn to eanble srgb capable test. maybe glutin forgot to add that?

Is the closure I'm passing to display_builder.build() correct regarding my intentions to match my previous code?

I don't think you care about the number of samples? the closure is for people who want maximum multi-sampling support, but you don't need that.

Why do I have to enable vsync in this weird way? :)

I have no idea.
openGL is weird. I am just happy that someone like glutin team are handling most of the complexity and protecting me from all the platform specific bugs.

that said, once the next release of egui is out, and if the number of bug reports are not too many, we can polish the eframe glutin backend for android and also do a pure glow example rewrite.

@Boscop
Copy link
Author

Boscop commented Dec 5, 2022

@coderedart Thanks. And should I use .with_profile(GlProfile::Core) or not? :)

@coderedart
Copy link
Contributor

@coderedart Thanks. And should I use .with_profile(GlProfile::Core) or not? :)

always use Core, unless you are targeting really ancient hardware.

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

No branches or pull requests

2 participants