From 3adf44a516abe397658fd16f3c1b61fd1707807c Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Thu, 4 Jul 2019 22:05:08 +0200 Subject: [PATCH] Added some extra display related functions. --- allg5/bitmap.go | 4 ++++ allg5/display.go | 10 +++++++++- ui/allg5ui/renderer.go | 2 ++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/allg5/bitmap.go b/allg5/bitmap.go index a6e8977..9a3e024 100644 --- a/allg5/bitmap.go +++ b/allg5/bitmap.go @@ -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) diff --git a/allg5/display.go b/allg5/display.go index cb1ac90..cb8e570 100644 --- a/allg5/display.go +++ b/allg5/display.go @@ -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() } diff --git a/ui/allg5ui/renderer.go b/ui/allg5ui/renderer.go index d162987..b190ae8 100644 --- a/ui/allg5ui/renderer.go +++ b/ui/allg5ui/renderer.go @@ -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)