Newer
Older
"github.com/faiface/mainthread"
// Monitor represents a physical display attached to your computer.
type Monitor struct {
monitor *glfw.Monitor
}
// PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff).
monitor := mainthread.CallVal(func() interface{} {
return glfw.GetPrimaryMonitor()
}).(*glfw.Monitor)
func Monitors() []*Monitor {
var monitors []*Monitor
mainthread.Call(func() {
for _, monitor := range glfw.GetMonitors() {
monitors = append(monitors, &Monitor{monitor: monitor})
}
})
name := mainthread.CallVal(func() interface{} {
return m.monitor.GetName()
}).(string)
return name
// PhysicalSize returns the size of the display area of the Monitor in millimeters.
func (m *Monitor) PhysicalSize() (width, height float64) {
mainthread.Call(func() {
wi, hi = m.monitor.GetPhysicalSize()
})
width = float64(wi)
height = float64(hi)
return
// Position returns the position of the upper-left corner of the Monitor in screen coordinates.
func (m *Monitor) Position() (x, y float64) {
mainthread.Call(func() {
x = float64(xi)
y = float64(yi)
return
func (m *Monitor) Size() (width, height float64) {
mode := mainthread.CallVal(func() interface{} {
return m.monitor.GetVideoMode()
}).(*glfw.VidMode)
width = float64(mode.Width)
height = float64(mode.Height)
return
// BitDepth returns the number of bits per color of the Monitor.
func (m *Monitor) BitDepth() (red, green, blue int) {
mode := mainthread.CallVal(func() interface{} {
return m.monitor.GetVideoMode()
}).(*glfw.VidMode)
red = mode.RedBits
green = mode.GreenBits
blue = mode.BlueBits
return
// RefreshRate returns the refresh frequency of the Monitor in Hz (refreshes/second).
func (m *Monitor) RefreshRate() (rate float64) {
mode := mainthread.CallVal(func() interface{} {
return m.monitor.GetVideoMode()
}).(*glfw.VidMode)
rate = float64(mode.RefreshRate)
return