glfw: Window hints get reverted to default after window creation and cannot be set #201
Labels
No labels
CI
all
basisu
blog
bug
build
contributor-friendly
core
correctness
deferred
dev
direct3d-headers
docs
driver-os-issue
duplicate
dxcompiler
editor
examples
experiment
feature-idea
feedback
flac
freetype
gamemode
gkurve
glfw
gpu
gpu-dawn
harfbuzz
help welcome
in-progress
infrastructure
invalid
libmach
linux-audio-headers
long-term
mach
mach.gfx
mach.math
mach.physics
mach.testing
model3d
needs-triage
object
opengl-headers
opus
os/linux
os/macos
os/wasm
os/windows
package-manager
priority
proposal
proposal-accepted
question
roadmap
slipped
stability
sysaudio
sysgpu
sysjs
validating-fix
vulkan-zig-generated
wayland-headers
website
wontfix
wrench
www
x11-headers
xcode-frameworks
zig-update
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
hexops/mach#201
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Once a window is created the GLFW wrapper resets all the hints to default. There is no public API available to set a hint so now we are stuck in a state where we can't work with hints at all. The README states that
hintis a public method but it is not.Possible fixes:
window.hintpubliccso that we can override and call raw GLFW methods ourselves when necessaryYou're correct the README is out of date. The idea is that you pass a struct to createWindow with the hints, it sets them for you, and resets to defaults after the fact.
Is this approach problematic for interior with other C code, or are you having trouble finding the struct where window hints get passed in?
The issue here is the resetting of the defaults. Once I set a hint I wouldn't expect it to get unset without me specifically requesting it. I came across the issue when adding Dear ImGui to my project. I set some hints and then Dear ImGui would create a window with
glfwCreateWindowSurfaceand it would fail assertions invulkan.cdue to theGLFW_CLIENT_APIhint being reset:Aha! Okay, now I understand. So
glfwCreateWindowSurfaceinternally relies on window hints. I did not realize this.The idea with hints being passed as a struct to
glfw.Window.createis that it becomes stateless: you pass in the desired state, we ensure it's that, then we wipe the state away afterwards (just because that seemed clean)But I see now that, actually, you sometimes need those window hints to be retained for longer periods of time.
In this case, I think that your suggestion of "don't reset hints after window creation" sounds good to me (in addition to exposing a method to reset them) - this way we keep the stateless aspect of
glfw.Window.createon it's own, and just leave the window hints in a "dirty" state.That sounds perfecto!