示例#1
0
文件: monitor.go 项目: godispy/glfw
//GetMonitors returns a slice of handles for all currently connected monitors.
func GetMonitors() ([]*Monitor, error) {
	var length int

	mC := C.glfwGetMonitors((*C.int)(unsafe.Pointer(&length)))

	if mC == nil {
		return nil, errors.New("Can't get the monitor list.")
	}

	m := make([]*Monitor, length)

	for i := 0; i < length; i++ {
		m[i] = &Monitor{C.GetMonitorAtIndex(mC, C.int(i))}
	}

	return m, nil
}
示例#2
0
文件: monitor.go 项目: godispy/glfw
// GetMonitors returns a slice of handles for all currently connected monitors.
func GetMonitors() []*Monitor {
	var length int

	mC := C.glfwGetMonitors((*C.int)(unsafe.Pointer(&length)))
	panicError()
	if mC == nil {
		return nil
	}

	m := make([]*Monitor, length)

	for i := 0; i < length; i++ {
		m[i] = &Monitor{C.GetMonitorAtIndex(mC, C.int(i))}
	}

	return m
}