Exemple #1
0
// 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
}
Exemple #2
0
// Clipboard
func SetClipboardString(window Window, s string) {
	cs := C.CString(s)
	defer C.free(unsafe.Pointer(cs))
	C.glfwSetClipboardString(C.GLFWwindow(window), cs)
}
Exemple #3
0
func ScrollOffset(window Window) (x, y float64) {
	var cx, cy C.double
	C.glfwGetScrollOffset(C.GLFWwindow(window), &cx, &cy)
	return float64(cx), float64(cy)
}
Exemple #4
0
func SetCursorPos(window Window, x, y int) {
	C.glfwSetCursorPos(C.GLFWwindow(window), C.int(x), C.int(y))
}
Exemple #5
0
func CursorPos(window Window) (x, y int) {
	var cx, cy C.int
	C.glfwGetCursorPos(C.GLFWwindow(window), &cx, &cy)
	return int(cx), int(cy)
}
Exemple #6
0
func MouseButton(window Window, button int) int {
	return int(C.glfwGetMouseButton(C.GLFWwindow(window), C.int(button)))
}
Exemple #7
0
func DestroyWindow(window Window) { C.glfwDestroyWindow(C.GLFWwindow(window)) }
Exemple #8
0
func SwapBuffers(window Window) {
	C.glfwSwapBuffers(C.GLFWwindow(window))
}
Exemple #9
0
// Input handling
func InputMode(window Window, mode int) int {
	return int(C.glfwGetInputMode(C.GLFWwindow(window), C.int(mode)))
}
Exemple #10
0
func WindowParam(window Window, param int) int {
	return int(C.glfwGetWindowParam(C.GLFWwindow(window), C.int(param)))
}
Exemple #11
0
func RestoreWindow(window Window) { C.glfwRestoreWindow(C.GLFWwindow(window)) }
Exemple #12
0
func IconifyWindow(window Window) { C.glfwIconifyWindow(C.GLFWwindow(window)) }
Exemple #13
0
func SetWindowSize(window Window, width, height int) {
	C.glfwSetWindowSize(C.GLFWwindow(window), C.int(width), C.int(height))
}
Exemple #14
0
func WindowSize(window Window) (int, int) {
	var w, h C.int
	C.glfwGetWindowSize(C.GLFWwindow(window), &w, &h)
	return int(w), int(h)
}
Exemple #15
0
func SetWindowTitle(window Window, title string) {
	cs := C.CString(title)
	defer C.free(unsafe.Pointer(cs))
	C.glfwSetWindowTitle(C.GLFWwindow(window), cs)
}
Exemple #16
0
func ClipboardString(window Window) string {
	cs := C.glfwGetClipboardString(C.GLFWwindow(window))
	return C.GoString(cs)
}
Exemple #17
0
// OpenGL support
func MakeContextCurrent(window Window) {
	C.glfwMakeContextCurrent(C.GLFWwindow(window))
}
Exemple #18
0
func SetInputMode(window Window, mode, value int) {
	C.glfwSetInputMode(C.GLFWwindow(window), C.int(mode), C.int(value))
}
Exemple #19
0
func CopyContext(source, destination Window, mask uint64) {
	C.glfwCopyContext(C.GLFWwindow(source), C.GLFWwindow(destination), C.ulong(mask))
}
Exemple #20
0
func Key(window Window, key int) int {
	return int(C.glfwGetKey(C.GLFWwindow(window), C.int(key)))
}