internal/glfw/glfw: refactoring

This commit is contained in:
Hajime Hoshi 2023-07-08 02:34:56 +09:00
parent fafbe2711f
commit c2b386a917
4 changed files with 6 additions and 10 deletions

View File

@ -78,7 +78,7 @@ func SwapInterval(interval int) {
func ExtensionSupported(extension string) bool {
e := C.CString(extension)
defer C.free(unsafe.Pointer(e))
ret := glfwbool(C.glfwExtensionSupported(e))
ret := C.glfwExtensionSupported(e) != 0
panicError()
return ret
}

View File

@ -283,7 +283,7 @@ func goCursorPosCB(window unsafe.Pointer, xpos, ypos C.double) {
//export goCursorEnterCB
func goCursorEnterCB(window unsafe.Pointer, entered C.int) {
w := windows.get((*C.GLFWwindow)(window))
hasEntered := glfwbool(entered)
hasEntered := entered != 0
w.fCursorEnterHolder(w, hasEntered)
}

View File

@ -9,10 +9,6 @@ package glfw
// #include <stdlib.h>
import "C"
func glfwbool(b C.int) bool {
return b == C.int(True)
}
func bytes(origin []byte) (pointer *uint8, free func()) {
n := len(origin)
if n == 0 {

View File

@ -270,7 +270,7 @@ func goWindowCloseCB(window unsafe.Pointer) {
//export goWindowMaximizeCB
func goWindowMaximizeCB(window unsafe.Pointer, maximized C.int) {
w := windows.get((*C.GLFWwindow)(window))
w.fMaximizeHolder(w, glfwbool(maximized))
w.fMaximizeHolder(w, maximized != 0)
}
//export goWindowRefreshCB
@ -282,13 +282,13 @@ func goWindowRefreshCB(window unsafe.Pointer) {
//export goWindowFocusCB
func goWindowFocusCB(window unsafe.Pointer, focused C.int) {
w := windows.get((*C.GLFWwindow)(window))
isFocused := glfwbool(focused)
isFocused := focused != 0
w.fFocusHolder(w, isFocused)
}
//export goWindowIconifyCB
func goWindowIconifyCB(window unsafe.Pointer, iconified C.int) {
isIconified := glfwbool(iconified)
isIconified := iconified != 0
w := windows.get((*C.GLFWwindow)(window))
w.fIconifyHolder(w, isIconified)
}
@ -409,7 +409,7 @@ func (w *Window) Destroy() {
// ShouldClose reports the value of the close flag of the specified window.
func (w *Window) ShouldClose() bool {
ret := glfwbool(C.glfwWindowShouldClose(w.data))
ret := C.glfwWindowShouldClose(w.data) != 0
panicError()
return ret
}