Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
GetKey(win, KEY_ESCAPE) == PRESS
work
`GetKey` is defined below to return a `Bool`, but in the documentation it is defined as returning `PRESS` or `RELEASE`. In C that doesn't matter, but in Julia these are different types and so e.g. `GLFW.GetKey(window, GLFW.KEY_ESCAPE)) == GLFW.PRESS` will always return false. This method tells Julia how to compare an `Action` and a `Bool` so that code calling `GetKey` as documented will work as expected. Julia will do slightly more work when comparing `Bool` and `Action` than when comparing two `Bool`s because it will expand the Bool to 32 bits first. This could be avoided by defining the basetype of the `Action` enum as `UInt8`, but that would be a breaking change if arrays of `Action` are ever passed to C (I don't think they would be, but idk). I tried to persuade Julia to omit the expansion to 32 bits, but I couldn't find anything that worked. Closest was `b == unsafe_trunc(Bool, a)`, but that still emits more instructions than comparing two `Bool`s.
- Loading branch information