Merge pull request #114 from dbriemann/feature/video-modes
Adds video mode support and a community example for its usage.
This commit is contained in:
commit
a8270e58e0
|
@ -10,6 +10,17 @@ type Monitor struct {
|
||||||
monitor *glfw.Monitor
|
monitor *glfw.Monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VideoMode represents all properties of a video mode and is
|
||||||
|
// associated with a monitor if it is used in fullscreen mode.
|
||||||
|
type VideoMode struct {
|
||||||
|
// Width is the width of the vide mode in pixels.
|
||||||
|
Width int
|
||||||
|
// Height is the height of the video mode in pixels.
|
||||||
|
Height int
|
||||||
|
// RefreshRate holds the refresh rate of the associated monitor in Hz.
|
||||||
|
RefreshRate int
|
||||||
|
}
|
||||||
|
|
||||||
// PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff).
|
// PrimaryMonitor returns the main monitor (usually the one with the taskbar and stuff).
|
||||||
func PrimaryMonitor() *Monitor {
|
func PrimaryMonitor() *Monitor {
|
||||||
var monitor *glfw.Monitor
|
var monitor *glfw.Monitor
|
||||||
|
@ -95,3 +106,19 @@ func (m *Monitor) RefreshRate() (rate float64) {
|
||||||
rate = float64(mode.RefreshRate)
|
rate = float64(mode.RefreshRate)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VideoModes returns all available video modes for the monitor.
|
||||||
|
func (m *Monitor) VideoModes() (vmodes []VideoMode) {
|
||||||
|
var modes []*glfw.VidMode
|
||||||
|
mainthread.Call(func() {
|
||||||
|
modes = m.monitor.GetVideoModes()
|
||||||
|
})
|
||||||
|
for _, mode := range modes {
|
||||||
|
vmodes = append(vmodes, VideoMode{
|
||||||
|
Width: mode.Width,
|
||||||
|
Height: mode.Height,
|
||||||
|
RefreshRate: mode.RefreshRate,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue