Added display & monitor functions
This commit is contained in:
parent
6bd3bad160
commit
dbcd09094f
@ -14,12 +14,11 @@ type Display struct {
|
||||
}
|
||||
|
||||
type NewDisplayOptions struct {
|
||||
Width int
|
||||
Height int
|
||||
Fullscreen bool
|
||||
Resizable bool
|
||||
Windowed bool
|
||||
Maximized bool
|
||||
Frameless bool
|
||||
}
|
||||
|
||||
// NewDisplay creates a display
|
||||
@ -31,6 +30,8 @@ func NewDisplay(width, height int, options NewDisplayOptions) (*Display, error)
|
||||
} else {
|
||||
flags = C.ALLEGRO_FULLSCREEN
|
||||
}
|
||||
} else if options.Frameless {
|
||||
flags |= C.ALLEGRO_FRAMELESS
|
||||
}
|
||||
if options.Resizable {
|
||||
flags |= C.ALLEGRO_RESIZABLE
|
||||
@ -65,10 +66,22 @@ func (d *Display) Position() (int, int) {
|
||||
return int(x), int(y)
|
||||
}
|
||||
|
||||
func (d *Display) Resize(w, h int) {
|
||||
C.al_resize_display(d.display, C.int(w), C.int(h))
|
||||
}
|
||||
|
||||
func (d *Display) SetAsTarget() {
|
||||
C.al_set_target_backbuffer(d.display)
|
||||
}
|
||||
|
||||
func (d *Display) SetMousePosition(x, y int) {
|
||||
C.al_set_mouse_xy(d.display, C.int(x), C.int(y))
|
||||
}
|
||||
|
||||
func (d *Display) SetPosition(x, y int) {
|
||||
C.al_set_window_position(d.display, C.int(x), C.int(y))
|
||||
}
|
||||
|
||||
func (d *Display) SetWindowTitle(title string) {
|
||||
t := C.CString(title)
|
||||
defer C.free(unsafe.Pointer(t))
|
||||
|
34
allegro5/monitor.go
Normal file
34
allegro5/monitor.go
Normal file
@ -0,0 +1,34 @@
|
||||
package allegro5
|
||||
|
||||
// #include <allegro5/allegro.h>
|
||||
import "C"
|
||||
|
||||
type Monitor struct {
|
||||
X1, Y1 int
|
||||
X2, Y2 int
|
||||
}
|
||||
|
||||
func monitor(m *C.ALLEGRO_MONITOR_INFO) Monitor {
|
||||
return Monitor{int(m.x1), int(m.y1), int(m.x2), int(m.y2)}
|
||||
}
|
||||
|
||||
func DefaultMonitor() Monitor {
|
||||
var m C.ALLEGRO_MONITOR_INFO
|
||||
C.al_get_monitor_info(C.ALLEGRO_DEFAULT_DISPLAY_ADAPTER, &m)
|
||||
return monitor(&m)
|
||||
}
|
||||
|
||||
func Monitors() []Monitor {
|
||||
var n = NumberOfVideoAdapters()
|
||||
var mons []Monitor
|
||||
var m C.ALLEGRO_MONITOR_INFO
|
||||
for i := 0; i < n; i++ {
|
||||
C.al_get_monitor_info(C.int(i), &m)
|
||||
mons = append(mons, monitor(&m))
|
||||
}
|
||||
return mons
|
||||
}
|
||||
|
||||
func NumberOfVideoAdapters() int {
|
||||
return int(C.al_get_num_video_adapters())
|
||||
}
|
Loading…
Reference in New Issue
Block a user