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
|
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 {
|
func (b *Bitmap) Image() image.Image {
|
||||||
im := image.NewRGBA(image.Rect(0, 0, b.width, b.height))
|
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)
|
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
|
Windowed bool
|
||||||
Maximized bool
|
Maximized bool
|
||||||
Frameless bool
|
Frameless bool
|
||||||
|
Shaders bool
|
||||||
|
OpenGL bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDisplay creates a display
|
// NewDisplay creates a display
|
||||||
@ -39,6 +41,12 @@ func NewDisplay(width, height int, options NewDisplayOptions) (*Display, error)
|
|||||||
flags |= C.ALLEGRO_MAXIMIZED
|
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)
|
C.al_set_new_display_flags(flags)
|
||||||
d := C.al_create_display(C.int(width), C.int(height))
|
d := C.al_create_display(C.int(width), C.int(height))
|
||||||
if d == nil {
|
if d == nil {
|
||||||
@ -47,7 +55,7 @@ func NewDisplay(width, height int, options NewDisplayOptions) (*Display, error)
|
|||||||
return &Display{d}, nil
|
return &Display{d}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flips flips the buffer to the display
|
// Flip flips the buffer to the display
|
||||||
func (d *Display) Flip() {
|
func (d *Display) Flip() {
|
||||||
C.al_flip_display()
|
C.al_flip_display()
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,8 @@ func (r *Renderer) DefaultTarget() ui.Image {
|
|||||||
return &uiImage{r.disp.Target()}
|
return &uiImage{r.disp.Target()}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Renderer) Display() *allg5.Display { return r.disp }
|
||||||
|
|
||||||
func (r *Renderer) DrawImage(im ui.Image, p geom.PointF32) {
|
func (r *Renderer) DrawImage(im ui.Image, p geom.PointF32) {
|
||||||
bmp := r.mustGetBitmap(im)
|
bmp := r.mustGetBitmap(im)
|
||||||
x, y := snap(p)
|
x, y := snap(p)
|
||||||
|
Loading…
Reference in New Issue
Block a user