Skip to content

add default methods to WindowOpenOptions#224

Open
BillyDM wants to merge 3 commits intoRustAudio:masterfrom
BillyDM:default_options
Open

add default methods to WindowOpenOptions#224
BillyDM wants to merge 3 commits intoRustAudio:masterfrom
BillyDM:default_options

Conversation

@BillyDM
Copy link
Copy Markdown
Contributor

@BillyDM BillyDM commented Mar 30, 2026

This will fix an annoying issue I'm having in my NIH-plug fork where rust-analyzer will get confused when some crates use the "opengl" feature and some don't. I have to add special crate features just to work around it.

With this, I can just use the ..Default::default() pattern to make both rust-analyzer and the rust compiler happy.

Comment thread src/window_open_options.rs Outdated
/// If provided, then an OpenGL context will be created for this window. You'll be able to
/// access this context through [crate::Window::gl_context].
///
/// By default this is set to `Some(GlConfig::default())`.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why default to Some(GlConfig::default())? It makes a lot more sense to me for it to default to None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If the user is using a GUI library that expects OpenGL, then the GUI would fail to open with the default settings.

Though I suppose the GUI library layer could add the OpenGL config itself. So I guess either method is fine.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we should be trying to guess what GUI libraries expect. Some GUI libraries may be using wgpu or software rendering, in which case defaulting to creating an OpenGL context will also cause problems. gl_config should default to None, and either the user or the GUI library should explicitly set it to something else if needed.

@BillyDM
Copy link
Copy Markdown
Contributor Author

BillyDM commented Apr 28, 2026

Alright, I made gl_config default to None.

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