mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +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 {
|
func ExtensionSupported(extension string) bool {
|
||||||
e := C.CString(extension)
|
e := C.CString(extension)
|
||||||
defer C.free(unsafe.Pointer(e))
|
defer C.free(unsafe.Pointer(e))
|
||||||
ret := glfwbool(C.glfwExtensionSupported(e))
|
ret := C.glfwExtensionSupported(e) != 0
|
||||||
panicError()
|
panicError()
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ func goCursorPosCB(window unsafe.Pointer, xpos, ypos C.double) {
|
|||||||
//export goCursorEnterCB
|
//export goCursorEnterCB
|
||||||
func goCursorEnterCB(window unsafe.Pointer, entered C.int) {
|
func goCursorEnterCB(window unsafe.Pointer, entered C.int) {
|
||||||
w := windows.get((*C.GLFWwindow)(window))
|
w := windows.get((*C.GLFWwindow)(window))
|
||||||
hasEntered := glfwbool(entered)
|
hasEntered := entered != 0
|
||||||
w.fCursorEnterHolder(w, hasEntered)
|
w.fCursorEnterHolder(w, hasEntered)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,10 +9,6 @@ package glfw
|
|||||||
// #include <stdlib.h>
|
// #include <stdlib.h>
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
func glfwbool(b C.int) bool {
|
|
||||||
return b == C.int(True)
|
|
||||||
}
|
|
||||||
|
|
||||||
func bytes(origin []byte) (pointer *uint8, free func()) {
|
func bytes(origin []byte) (pointer *uint8, free func()) {
|
||||||
n := len(origin)
|
n := len(origin)
|
||||||
if n == 0 {
|
if n == 0 {
|
||||||
|
@ -270,7 +270,7 @@ func goWindowCloseCB(window unsafe.Pointer) {
|
|||||||
//export goWindowMaximizeCB
|
//export goWindowMaximizeCB
|
||||||
func goWindowMaximizeCB(window unsafe.Pointer, maximized C.int) {
|
func goWindowMaximizeCB(window unsafe.Pointer, maximized C.int) {
|
||||||
w := windows.get((*C.GLFWwindow)(window))
|
w := windows.get((*C.GLFWwindow)(window))
|
||||||
w.fMaximizeHolder(w, glfwbool(maximized))
|
w.fMaximizeHolder(w, maximized != 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export goWindowRefreshCB
|
//export goWindowRefreshCB
|
||||||
@ -282,13 +282,13 @@ func goWindowRefreshCB(window unsafe.Pointer) {
|
|||||||
//export goWindowFocusCB
|
//export goWindowFocusCB
|
||||||
func goWindowFocusCB(window unsafe.Pointer, focused C.int) {
|
func goWindowFocusCB(window unsafe.Pointer, focused C.int) {
|
||||||
w := windows.get((*C.GLFWwindow)(window))
|
w := windows.get((*C.GLFWwindow)(window))
|
||||||
isFocused := glfwbool(focused)
|
isFocused := focused != 0
|
||||||
w.fFocusHolder(w, isFocused)
|
w.fFocusHolder(w, isFocused)
|
||||||
}
|
}
|
||||||
|
|
||||||
//export goWindowIconifyCB
|
//export goWindowIconifyCB
|
||||||
func goWindowIconifyCB(window unsafe.Pointer, iconified C.int) {
|
func goWindowIconifyCB(window unsafe.Pointer, iconified C.int) {
|
||||||
isIconified := glfwbool(iconified)
|
isIconified := iconified != 0
|
||||||
w := windows.get((*C.GLFWwindow)(window))
|
w := windows.get((*C.GLFWwindow)(window))
|
||||||
w.fIconifyHolder(w, isIconified)
|
w.fIconifyHolder(w, isIconified)
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ func (w *Window) Destroy() {
|
|||||||
|
|
||||||
// ShouldClose reports the value of the close flag of the specified window.
|
// ShouldClose reports the value of the close flag of the specified window.
|
||||||
func (w *Window) ShouldClose() bool {
|
func (w *Window) ShouldClose() bool {
|
||||||
ret := glfwbool(C.glfwWindowShouldClose(w.data))
|
ret := C.glfwWindowShouldClose(w.data) != 0
|
||||||
panicError()
|
panicError()
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user