// Window handling func CreateWindow(width, height, mode int, title string, share Window) (window Window, err error) { csTitle := C.CString(title) window = Window(C.glfwCreateWindow( C.int(width), C.int(height), C.int(mode), csTitle, C.GLFWwindow(share))) C.free(unsafe.Pointer(csTitle)) if window == nil { err = errors.New("Failed to open window") } return }
// Clipboard func SetClipboardString(window Window, s string) { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) C.glfwSetClipboardString(C.GLFWwindow(window), cs) }
func ScrollOffset(window Window) (x, y float64) { var cx, cy C.double C.glfwGetScrollOffset(C.GLFWwindow(window), &cx, &cy) return float64(cx), float64(cy) }
func SetCursorPos(window Window, x, y int) { C.glfwSetCursorPos(C.GLFWwindow(window), C.int(x), C.int(y)) }
func CursorPos(window Window) (x, y int) { var cx, cy C.int C.glfwGetCursorPos(C.GLFWwindow(window), &cx, &cy) return int(cx), int(cy) }
func MouseButton(window Window, button int) int { return int(C.glfwGetMouseButton(C.GLFWwindow(window), C.int(button))) }
func DestroyWindow(window Window) { C.glfwDestroyWindow(C.GLFWwindow(window)) }
func SwapBuffers(window Window) { C.glfwSwapBuffers(C.GLFWwindow(window)) }
// Input handling func InputMode(window Window, mode int) int { return int(C.glfwGetInputMode(C.GLFWwindow(window), C.int(mode))) }
func WindowParam(window Window, param int) int { return int(C.glfwGetWindowParam(C.GLFWwindow(window), C.int(param))) }
func RestoreWindow(window Window) { C.glfwRestoreWindow(C.GLFWwindow(window)) }
func IconifyWindow(window Window) { C.glfwIconifyWindow(C.GLFWwindow(window)) }
func SetWindowSize(window Window, width, height int) { C.glfwSetWindowSize(C.GLFWwindow(window), C.int(width), C.int(height)) }
func WindowSize(window Window) (int, int) { var w, h C.int C.glfwGetWindowSize(C.GLFWwindow(window), &w, &h) return int(w), int(h) }
func SetWindowTitle(window Window, title string) { cs := C.CString(title) defer C.free(unsafe.Pointer(cs)) C.glfwSetWindowTitle(C.GLFWwindow(window), cs) }
func ClipboardString(window Window) string { cs := C.glfwGetClipboardString(C.GLFWwindow(window)) return C.GoString(cs) }
// OpenGL support func MakeContextCurrent(window Window) { C.glfwMakeContextCurrent(C.GLFWwindow(window)) }
func SetInputMode(window Window, mode, value int) { C.glfwSetInputMode(C.GLFWwindow(window), C.int(mode), C.int(value)) }
func CopyContext(source, destination Window, mask uint64) { C.glfwCopyContext(C.GLFWwindow(source), C.GLFWwindow(destination), C.ulong(mask)) }
func Key(window Window, key int) int { return int(C.glfwGetKey(C.GLFWwindow(window), C.int(key))) }