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

api: fix NoError and debug requests #1636

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
- **Breaking:** `GlContext` trait is now a part of the `prelude`.
- Automatically cleanup the `EGLDisplay` when `EGL_KHR_display_reference` is present.
- Add `api::egl::Display::terminate` to terminate the display when glutin doesn't manage it.
- Fixed handling of `Robustness::NoError` and `debug` attribute when building context.
- `Robustness::NoError` not being properly enabled with GLX/WGL.

# Version 0.30.10

Expand Down
9 changes: 6 additions & 3 deletions glutin/src/api/egl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ impl Display {
}

let has_robustsess = self.inner.features.contains(DisplayFeatures::CONTEXT_ROBUSTNESS);
let has_no_error = self.inner.features.contains(DisplayFeatures::CONTEXT_NO_ERROR);

let mut requested_no_error = false;
match context_attributes.robustness {
Robustness::NotRobust => (),
Robustness::NoError if has_no_error => {
Robustness::NoError
if self.inner.features.contains(DisplayFeatures::CONTEXT_NO_ERROR) =>
{
attrs.push(egl::CONTEXT_OPENGL_NO_ERROR_KHR as EGLint);
attrs.push(egl::TRUE as EGLint);
requested_no_error = true;
},
Robustness::RobustLoseContextOnReset if has_robustsess => {
attrs.push(egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY as EGLint);
Expand All @@ -105,7 +108,7 @@ impl Display {
},
}

if context_attributes.debug && is_one_five && !has_no_error {
if context_attributes.debug && is_one_five && !requested_no_error {
attrs.push(egl::CONTEXT_OPENGL_DEBUG as EGLint);
attrs.push(egl::TRUE as EGLint);
}
Expand Down
5 changes: 4 additions & 1 deletion glutin/src/api/glx/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ impl Display {
}

let mut flags: c_int = 0;
let mut requested_no_error = false;
if self.inner.features.contains(DisplayFeatures::CONTEXT_ROBUSTNESS) {
match context_attributes.robustness {
Robustness::NotRobust => (),
Expand All @@ -144,6 +145,8 @@ impl Display {
}

attrs.push(glx_extra::CONTEXT_OPENGL_NO_ERROR_ARB as c_int);
attrs.push(1);
requested_no_error = true;
},
}
} else if context_attributes.robustness != Robustness::NotRobust {
Expand All @@ -154,7 +157,7 @@ impl Display {
}

// Debug flag.
if context_attributes.debug {
if context_attributes.debug && !requested_no_error {
flags |= glx_extra::CONTEXT_DEBUG_BIT_ARB as c_int;
}

Expand Down
5 changes: 4 additions & 1 deletion glutin/src/api/wgl/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl Display {
}

let mut flags: c_int = 0;
let mut requested_no_error = false;
if self.inner.features.contains(DisplayFeatures::CONTEXT_ROBUSTNESS) {
match context_attributes.robustness {
Robustness::NotRobust => (),
Expand All @@ -151,6 +152,8 @@ impl Display {
}

attrs.push(wgl_extra::CONTEXT_OPENGL_NO_ERROR_ARB as c_int);
attrs.push(1);
requested_no_error = true;
},
}
} else if context_attributes.robustness != Robustness::NotRobust {
Expand All @@ -161,7 +164,7 @@ impl Display {
}

// Debug flag.
if context_attributes.debug {
if context_attributes.debug && !requested_no_error {
flags |= wgl_extra::CONTEXT_DEBUG_BIT_ARB as c_int;
}

Expand Down
1 change: 1 addition & 0 deletions glutin/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl ContextAttributesBuilder {
/// Sets the *debug* flag for the OpenGL context.
///
/// Debug contexts are usually slower, but give better error reporting.
/// This option is ignored when using [`Robustness::NoError`].
///
/// The default value for this flag is `false`.
pub fn with_debug(mut self, debug: bool) -> Self {
Expand Down
Loading