internal/glfw, internal/graphicsdriver/opengl/gl: Use the last byte to detect a bool

When a C function returns a bool value, only the first byte of a
uintptr value matters. When we want to get a bool value from a C
function, filter this for sefety.
This commit is contained in:
Hajime Hoshi 2021-08-25 02:08:07 +09:00
parent 2e2813ab78
commit d1c764640d
2 changed files with 7 additions and 7 deletions

View File

@ -301,7 +301,7 @@ func (w *Window) SetTitle(title string) {
func (w *Window) ShouldClose() bool {
r := glfwDLL.call("glfwWindowShouldClose", w.w)
panicError()
return r == True
return byte(r) == True
}
func (w *Window) Show() {
@ -494,7 +494,7 @@ func Init() error {
func (j Joystick) Present() bool {
r := glfwDLL.call("glfwJoystickPresent", uintptr(j))
panicError()
return r == True
return byte(r) == True
}
func panicErrorExceptForInvalidValue() {
@ -556,7 +556,7 @@ func UpdateGamepadMappings(mapping string) bool {
defer runtime.KeepAlive(m)
r := glfwDLL.call("glfwUpdateGamepadMappings", uintptr(unsafe.Pointer(&m[0])))
panicError()
return r == True
return byte(r) == True
}
func WaitEvents() {

View File

@ -315,22 +315,22 @@ func GetVertexArrayPointeri_vEXT(vaobj uint32, index uint32, pname uint32, param
func IsFramebufferEXT(framebuffer uint32) bool {
ret, _, _ := syscall.Syscall(gpIsFramebufferEXT, 1, uintptr(framebuffer), 0, 0)
return ret != 0
return byte(ret) != 0
}
func IsProgram(program uint32) bool {
ret, _, _ := syscall.Syscall(gpIsProgram, 1, uintptr(program), 0, 0)
return ret != 0
return byte(ret) != 0
}
func IsRenderbufferEXT(renderbuffer uint32) bool {
ret, _, _ := syscall.Syscall(gpIsRenderbufferEXT, 1, uintptr(renderbuffer), 0, 0)
return ret != 0
return byte(ret) != 0
}
func IsTexture(texture uint32) bool {
ret, _, _ := syscall.Syscall(gpIsTexture, 1, uintptr(texture), 0, 0)
return ret != 0
return byte(ret) != 0
}
func LinkProgram(program uint32) {