diff --git a/monitor.go b/monitor.go index 022e904..5e11845 100644 --- a/monitor.go +++ b/monitor.go @@ -11,8 +11,8 @@ type Monitor struct { } // PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff). -func PrimaryMonitor() Monitor { - m := Monitor{} +func PrimaryMonitor() *Monitor { + m := &Monitor{} pixelgl.Do(func() { m.monitor = glfw.GetPrimaryMonitor() }) @@ -20,25 +20,25 @@ func PrimaryMonitor() Monitor { } // Monitors returns a slice of all currently attached monitors. -func Monitors() []Monitor { - var monitors []Monitor +func Monitors() []*Monitor { + var monitors []*Monitor pixelgl.Do(func() { for _, monitor := range glfw.GetMonitors() { - monitors = append(monitors, Monitor{monitor: monitor}) + monitors = append(monitors, &Monitor{monitor: monitor}) } }) return monitors } // Name returns a human-readable name of a monitor. -func (m Monitor) Name() string { +func (m *Monitor) Name() string { return pixelgl.DoVal(func() interface{} { return m.monitor.GetName() }).(string) } // PhysicalSize returns the size of the display are of a monitor in millimeters. -func (m Monitor) PhysicalSize() (width, height float64) { +func (m *Monitor) PhysicalSize() (width, height float64) { var w, h float64 pixelgl.Do(func() { wi, hi := m.monitor.GetPhysicalSize() @@ -49,7 +49,7 @@ func (m Monitor) PhysicalSize() (width, height float64) { } // Position returns the position of the upper-left corner of a monitor in screen coordinates. -func (m Monitor) Position() (x, y float64) { +func (m *Monitor) Position() (x, y float64) { pixelgl.Do(func() { xi, yi := m.monitor.GetPos() x = float64(xi) @@ -59,7 +59,7 @@ func (m Monitor) Position() (x, y float64) { } // Size returns the resolution of a monitor in pixels. -func (m Monitor) Size() (width, height float64) { +func (m *Monitor) Size() (width, height float64) { var w, h float64 pixelgl.Do(func() { mode := m.monitor.GetVideoMode() @@ -70,7 +70,7 @@ func (m Monitor) Size() (width, height float64) { } // BitDepth returns the number of bits per color of a monitor. -func (m Monitor) BitDepth() (red, green, blue int) { +func (m *Monitor) BitDepth() (red, green, blue int) { var r, g, b int pixelgl.Do(func() { mode := m.monitor.GetVideoMode() @@ -82,7 +82,7 @@ func (m Monitor) BitDepth() (red, green, blue int) { } // RefreshRate returns the refresh frequency of a monitor in Hz (refreshes/second). -func (m Monitor) RefreshRate() float64 { +func (m *Monitor) RefreshRate() float64 { var rate float64 pixelgl.Do(func() { mode := m.monitor.GetVideoMode()