fix: CGL: try to init pixel format without explicit profile before falling back to profile selection#1740
Open
kalzoo wants to merge 1 commit intorust-windowing:masterfrom
Open
Conversation
kchibisov
requested changes
Feb 24, 2026
Member
kchibisov
left a comment
There was a problem hiding this comment.
Need changelog entry for that.
|
|
||
| // Automatically pick the latest profile. | ||
| let raw = [ | ||
| NSOpenGLProfileVersion4_1Core, |
Member
There was a problem hiding this comment.
Can you make it into e.g. [(0, 0), (NSOpenGLProfileVersion4_1Core, NSOpenGLPFAOpenGLProfile), ...] so we don't have this back and forth. It doesn't really matter how many elements we have as long as its terminated with len.
There was a problem hiding this comment.
Not sure if the PR author is subscribed to the PR thread. Perhaps you can modify it manually @kchibisov? This would be a nice to have fix since it completely blocks macOS visualization from working in my crate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG.mdif knowledge of this change could be valuable to usersUpdated documentation to reflect any user-facing changes, including notes of platform-specific behaviorCreated or updated an example program if it would help users understand this functionalityNote: I am not experienced with OpenGL. This contribution fixes a bug "on my machine" but I can't say for certain that it is correct in general.
Problem
On macOS, the current implementation always adds
NSOpenGLPFAOpenGLProfilewhen creating pixel formats, then iterates through profiles (4.1 Core, 3.2 Core, Legacy) until one succeeds.This differs from GLFW's behavior. When GLFW receives no explicit
GLFW_CONTEXT_VERSION_*hints, it does not addNSOpenGLPFAOpenGLProfileat all (see nsgl_context.m here and here )The difference matters because:
This causes compatibility issues for applications that need both fixed-function OpenGL (only available in Legacy profile) and ARB_framebuffer_object (not exposed as an extension in strict Legacy mode, only in 3.0+ or unspecified contexts).
In my case, that was
mujoco-rs, issue here.(Red herring - same error message, but not caused by or using
glutin: google-deepmind/mujoco#1778 )Solution
So, I changed that section to try creating the pixel format without any
NSOpenGLPFAOpenGLProfilefirst. If that fails, fall back to the existing/previous explicit profile iteration.Testing
Tested on macOS with applications using MuJoCo physics engine rendering, which requires both fixed-function GL and ARB_framebuffer_object. Previously failed with
OpenGL ARB_framebuffer_object requirederror; now works correctly. Also,cargo testpassed. No other testing performed.