Added some extra display related functions.
This commit is contained in:
parent
3bd4001cc3
commit
3adf44a516
@ -220,6 +220,10 @@ func (b *Bitmap) Height() int {
|
||||
return b.height
|
||||
}
|
||||
|
||||
func (b *Bitmap) IsVideo() bool {
|
||||
return C.al_get_bitmap_flags(b.bitmap)&C.ALLEGRO_VIDEO_BITMAP == C.ALLEGRO_VIDEO_BITMAP
|
||||
}
|
||||
|
||||
func (b *Bitmap) Image() image.Image {
|
||||
im := image.NewRGBA(image.Rect(0, 0, b.width, b.height))
|
||||
region := C.al_lock_bitmap(b.bitmap, C.ALLEGRO_PIXEL_FORMAT_ABGR_8888, C.ALLEGRO_LOCK_READONLY)
|
||||
|
@ -19,6 +19,8 @@ type NewDisplayOptions struct {
|
||||
Windowed bool
|
||||
Maximized bool
|
||||
Frameless bool
|
||||
Shaders bool
|
||||
OpenGL bool
|
||||
}
|
||||
|
||||
// NewDisplay creates a display
|
||||
@ -39,6 +41,12 @@ func NewDisplay(width, height int, options NewDisplayOptions) (*Display, error)
|
||||
flags |= C.ALLEGRO_MAXIMIZED
|
||||
}
|
||||
}
|
||||
if options.OpenGL {
|
||||
flags |= C.ALLEGRO_OPENGL
|
||||
}
|
||||
if options.Shaders {
|
||||
flags |= C.ALLEGRO_PROGRAMMABLE_PIPELINE
|
||||
}
|
||||
C.al_set_new_display_flags(flags)
|
||||
d := C.al_create_display(C.int(width), C.int(height))
|
||||
if d == nil {
|
||||
@ -47,7 +55,7 @@ func NewDisplay(width, height int, options NewDisplayOptions) (*Display, error)
|
||||
return &Display{d}, nil
|
||||
}
|
||||
|
||||
// Flips flips the buffer to the display
|
||||
// Flip flips the buffer to the display
|
||||
func (d *Display) Flip() {
|
||||
C.al_flip_display()
|
||||
}
|
||||
|
@ -149,6 +149,8 @@ func (r *Renderer) DefaultTarget() ui.Image {
|
||||
return &uiImage{r.disp.Target()}
|
||||
}
|
||||
|
||||
func (r *Renderer) Display() *allg5.Display { return r.disp }
|
||||
|
||||
func (r *Renderer) DrawImage(im ui.Image, p geom.PointF32) {
|
||||
bmp := r.mustGetBitmap(im)
|
||||
x, y := snap(p)
|
||||
|
Loading…
Reference in New Issue
Block a user