//GetVideoModes returns an array of all video modes supported by the monitor. //The returned array is sorted in ascending order, first by color bit depth //(the sum of all channel depths) and then by resolution area (the product of //width and height). func (m *Monitor) GetVideoModes() ([]*VideoMode, error) { var length int vC := C.glfwGetVideoModes(m.data, (*C.int)(unsafe.Pointer(&length))) if vC == nil { return nil, errors.New("Can't get the video mode list.") } v := make([]*VideoMode, length) for i := 0; i < length; i++ { t := C.GetVidmodeAtIndex(vC, C.int(i)) v[i] = &VideoMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)} } return v, nil }
// GetVideoModes returns an array of all video modes supported by the monitor. // The returned array is sorted in ascending order, first by color bit depth // (the sum of all channel depths) and then by resolution area (the product of // width and height). func (m *Monitor) GetVideoModes() []*VidMode { var length int vC := C.glfwGetVideoModes(m.data, (*C.int)(unsafe.Pointer(&length))) panicError() if vC == nil { return nil } v := make([]*VidMode, length) for i := 0; i < length; i++ { t := C.GetVidmodeAtIndex(vC, C.int(i)) v[i] = &VidMode{int(t.width), int(t.height), int(t.redBits), int(t.greenBits), int(t.blueBits), int(t.refreshRate)} } return v }
// VideoModes returns a list of supported video modes. // // The returned list is sorted, first by color depth (RedBits + GreenBits + BlueBits), // and then by resolution (W idth × Height), with the lowest resolution, fewest // bits per pixel mode first. func VideoModes(max int) []*VidMode { var vm C.GLFWvidmode size := int(unsafe.Sizeof(vm)) ptr := (*C.GLFWvidmode)(C.malloc(C.size_t(size * max))) defer C.free(unsafe.Pointer(ptr)) count := C.glfwGetVideoModes(ptr, C.int(max)) if count == 0 { return nil } list := make([]*VidMode, count) for i := range list { p := (*C.GLFWvidmode)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) + uintptr(i*size))) list[i] = vidModeFromPtr(p) } return list }