adds a community example for the usage of video modes
This commit is contained in:
parent
9817425914
commit
2a1ab90ad5
|
@ -10,6 +10,15 @@ type Monitor struct {
|
||||||
monitor *glfw.Monitor
|
monitor *glfw.Monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VideoMode represents all properties of a video mode and is attached
|
||||||
|
// to a monitor if it is a fullscreen mode.
|
||||||
|
type VideoMode struct {
|
||||||
|
*glfw.VidMode
|
||||||
|
// Monitor is a pointer to the monitor that owns this video mode.
|
||||||
|
// If Monitor is nil the video mode is windowed.
|
||||||
|
Monitor *Monitor
|
||||||
|
}
|
||||||
|
|
||||||
// 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 +104,18 @@ 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{
|
||||||
|
VidMode: mode,
|
||||||
|
Monitor: m,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -424,3 +424,9 @@ func (w *Window) Clear(c color.Color) {
|
||||||
func (w *Window) Color(at pixel.Vec) pixel.RGBA {
|
func (w *Window) Color(at pixel.Vec) pixel.RGBA {
|
||||||
return w.canvas.Color(at)
|
return w.canvas.Color(at)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetVideoMode applies the given video mode to this window.
|
||||||
|
func (w *Window) SetVideoMode(vm VideoMode) {
|
||||||
|
w.SetMonitor(vm.Monitor)
|
||||||
|
w.SetBounds(pixel.R(0, 0, float64(vm.Width), float64(vm.Height)))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue