mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/glfw/glfw: refactoring
This commit is contained in:
parent
fafbe2711f
commit
c2b386a917
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user