blob: 931484a3ce8fae3f76085f5f997cf6f981270333 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package win
import (
"github.com/faiface/mainthread"
"github.com/go-gl/glfw/v3.2/glfw"
)
// Holds information on a monitor
type Monitor struct {
Width, Height int
RefreshRate int
}
// Returns a struct containing information about the primary monitor
func GetPrimaryMonitor() (Monitor, error) {
returns := mainthread.CallVal( func() interface{} {
err := glfw.Init()
if err != nil {
return err
}
return glfw.GetPrimaryMonitor().GetVideoMode()
})
monitor := Monitor{0, 0, 0}
var err error = nil
switch v := returns.(type) {
case *glfw.VidMode:
videoMode := v
width := videoMode.Width
height := videoMode.Height
refreshRate := videoMode.RefreshRate
monitor = Monitor{width, height, refreshRate}
case error:
err = v
}
return monitor, err
}
|