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
glfw: Window hints rework #71
Conversation
I had this thought initially too, but if you look at the GLFW source, it's probably about the same as calling If you do want to avoid setting hints that don't need changed though, I'd still recommend going the struct route, and just check if the value is different than the default. This is easy to do by just looping over A struct results in a nicer API than an array of hints - the latter still feels very much like a C API, not a Zig one. |
@silversquirl Good point. I don't know why I didn't actually check the source; guess that's what I get for starting this on my laptop at a café. And I guess that's also why I made this a draft. |
@silversquirl Do you have any thoughts on what to do with the currently unused |
Either move the type conversion logic in |
Excuse my fumbling with git, trying to make the history not look messy. |
…he tests to reflect this, add doc comment line
…ssage in this unlikely edge case
…ecified to be a Window creation hint by the docs, and affirm removal of `Hint.context_revision`, which isn't. The docs don't seem to specify a default value for `Hints.context_no_error` to take on, so we could set it based on `std.debug.runtime_safety` like this.
…ion about its usage as suggested.
…xtRobustness`, `ContextReleaseBehavior`, and `OpenGlProfile` from consts.zig, and remove the now unused constants (replaced by aformentioned enum values).
…o ensure fields are the same
Thanks for all your work on this! It'll probably be a few days before I have a chance to review (at handmade Seattle and then to a wedding) so apologies for the delayed review! |
I had an idea to maybe add a test that compares the attribute values of a window created with |
@InKryption regarding:
This sounds like an obvious win to me, so yes, please do! I won't block this PR on this, please send another PR for it if I merge before you get to it. One thing to be mindful of: if we want the test to pass on any OS, be sure to choose hints that work on all OS/platforms. |
@slimsag Roger roger, I'll set this as ready for merging then, in the absence of any notes you may have. |
Co-authored-by: Stephen Gutekanst <stephen.gutekanst@gmail.com>
…naming convention Co-authored-by: Stephen Gutekanst <stephen.gutekanst@gmail.com>
Co-authored-by: Stephen Gutekanst <stephen.gutekanst@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really great, thanks for sending this. Once my comments are addressed and tests pass I'll merge. Feel free to send the test in this PR or a separate one, whichever you prefer.
…ig'; fix anything referencing it.
Looks good to me, let me know when you're finished and I'll merge. I will need to squash merge due to non-linear history, unless you want to rebase everything (I'm happy either way) |
…rely according to current GLFW docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a ton again!
Closes #65 |
I took a different approach to the one used for initialization hints, because I realized that it would probably a lot of overhead to callWindow.hint
for every possible hint, compared to how status quo allows one to avoid that overhead; as well, it would probably be a lot harder to maintain, given that, unlikeInitHint
, window initialization hints are of more types than just booleans.This approach is (quite a bit) more verbose, but avoids the overhead, and probably makes it easier to maintain.Also, I found that
context_revision
andcontext_no_error
are listed inWindow.Hint
, but are not listed as hints in the docs, only as attributes; I commented them out to make what I have pass tests - is this intentional and I'm missing something, or is this the result of some mishap?Edit:
it should also be noted that unlike the change made to initialization hints, I didn't completely re-use the in-place API, because I ran into some issues regarding the type-inference in theWindow.hint
function, so you'll see I ended up re-implementing the code forWindow.hint
inHintValue.set
(whereHintValue
is a tagged union, with a tag type ofHint
).Edit: as pointed out by @silversquirl, there isn't actually a lot of overhead involved in the struct approach, so now the union slice is no more.
Now just to address the other components of this problem, such asWindow.hint
, which seems to have some some type inference issues which caused compilation to fail under this new model. Should we try and rework it, or discard it in favor ofHints.set
(private function)?Edit: Closes #65