Browse Source

Change some names and convert to a package.

Beoran 5 years ago
parent
commit
be7a9edfcb
21 changed files with 276 additions and 126 deletions
  1. 24 12
      al/al.go
  2. 14 14
      al/al_test.go
  3. 42 36
      al/bitmap.go
  4. 3 3
      al/blender.go
  5. 20 10
      al/display.go
  6. 36 9
      al/event.go
  7. 7 2
      al/font.go
  8. 4 4
      al/image.go
  9. 16 16
      al/joystick.go
  10. 2 2
      al/keyboard.go
  11. 7 7
      al/memfile.go
  12. 2 2
      al/mode.go
  13. 5 5
      al/mouse.go
  14. 8 1
      al/primitives.go
  15. 1 1
      al/shader.go
  16. 2 2
      al/touch_input.go
  17. 12 0
      al/transformations.go
  18. 1 0
      go.mod
  19. 15 0
      mainthread/mainthread.go
  20. 0 0
      pkg/.gitkeep
  21. 55 0
      tool/gentype

+ 24 - 12
al/al.go

@@ -72,7 +72,7 @@ func IsSystemInstalled() bool {
 }
 
 // Gets the raw version of Allegro linked to as an integer.
-func GetAllegroVersion() uint32 {
+func AllegroVersion() uint32 {
     return uint32(C.al_get_allegro_version())
 }
 
@@ -151,20 +151,32 @@ func (self *Path) Destroy() {
 }
 
 // Gets amount of components of the path name
-func (self *Path) GetPathNumComponents() int {
+func (self *Path) NumComponents() int {
     return int(C.al_get_path_num_components(self.handle))
 }
 
-// converst the allegro path to a string 
+// Gets the index'th component of the path name
+func (path *Path) Component(index int) string {
+    return C.GoString(C.al_get_path_component(path.handle, C.int(index)))
+}
+
+
+// Converts the allegro path to a string 
 func (self *Path) String() string {
     return gostr(C.al_path_cstr(self.handle, C.char(NATIVE_PATH_SEP)))
 }
 
+
+func (path * Path) MakeCanonical() * Path {
+    C.al_make_path_canonical(path.handle)
+    return path
+}
+
+
 /*
 func (self * Path) 
 
 
-AL_FUNC(int, al_get_path_num_components, (const ALLEGRO_PATH *path));
 AL_FUNC(const char*, al_get_path_component, (const ALLEGRO_PATH *path, int i));
 AL_FUNC(void, al_replace_path_component, (ALLEGRO_PATH *path, int i, const char *s));
 AL_FUNC(void, al_remove_path_component, (ALLEGRO_PATH *path, int i));
@@ -207,7 +219,7 @@ const (
 )
 
 // Gets a standard path location.
-func GetStandardPath(id int) *Path {
+func StandardPath(id int) *Path {
     return wrapPath(C.al_get_standard_path(C.int(id)))
 }
 
@@ -226,13 +238,13 @@ func SetAppName(name string) {
     C.al_set_app_name(cstr(name))
 }
 
-// Gets the name of the organisation
-func GetOrgName() string {
+// Gets the name of the organisation for an app
+func OrgName() string {
     return gostr(C.al_get_org_name())
 }
 
-// Sets the name of the app
-func GetAppName() string {
+// Gets the name of the app
+func AppName() string {
     return gostr(C.al_get_app_name())
 }
 
@@ -386,12 +398,12 @@ func (self *Timer) SetSpeed(speed_secs float64) {
 }
 
 // Gets the speed of the timer.
-func (self *Timer) GetSpeed() float64 {
+func (self *Timer) Speed() float64 {
     return float64(C.al_get_timer_speed(self.handle))
 }
 
 // Gets the count (in ticks) of the timer
-func (self *Timer) GetCount() int {
+func (self *Timer) Count() int {
     return int(C.al_get_timer_count(self.handle))
 }
 
@@ -407,7 +419,7 @@ func (self *Timer) AddCount(count int) {
 
 // Gets the event source of this timer that can be registered 
 // on an event queue with RegisterEventSource.
-func (self *Timer) GetEventSource() *EventSource {
+func TimerEventSource(self * Timer) *EventSource {
     return (*EventSource)(C.al_get_timer_event_source(self.handle))
 }
 

+ 14 - 14
al/al_test.go

@@ -15,7 +15,7 @@ const TEST_FULLSCREEN = true
 var fullscreen = flag.Bool("fullscreen", false, "Run fullscreen or not")
 
 func TestGetAllegroVersion(t *testing.T) {
-    version := GetAllegroVersion()
+    version := AllegroVersion()
     if version != expected_version {
         t.Errorf("unexpected version of Allegro: %d in stead of %d!",
             version, expected_version)
@@ -102,7 +102,7 @@ func TestGetTimeRest(t *testing.T) {
 func TestPath(t *testing.T) {    
     InstallSystem()
     defer UninstallSystem()    
-    path := GetStandardPath(TEMP_PATH)
+    path := StandardPath(TEMP_PATH)
     str := path.String()
     tmp := "/tmp/"
     // special case for windows...
@@ -123,7 +123,7 @@ func TestGetInfo(t *testing.T) {
         t.Error("No video adapters found!")
     }
     for index := 0; index < nv; index++ {
-        info := GetMonitorInfo(index)
+        info := FindMonitorInfo(index)
         if info == nil {
             t.Errorf("Video adapter %d not found!", index)
             continue
@@ -149,28 +149,28 @@ func TestJoystick(t *testing.T) {
     defer UninstallSystem()
     InstallJoystick()
     defer UninstallJoystick()
-    num := GetNumJoysticks()
+    num := NumJoysticks()
     t.Logf("Found %d joysticks\n", num)
     for index := 0; index < num; index++ {
-        js := GetJoystick(index)
-        jsname := js.GetName()
-        sticks := js.GetNumSticks()
-        buttons := js.GetNumButtons()
+        js := FindJoystick(index)
+        jsname := js.Name()
+        sticks := js.NumSticks()
+        buttons := js.NumButtons()
         t.Logf("Joystick %s (nr %d) has %d sticks and %d buttons:\n",
             jsname, index, sticks, buttons)
         for sdex := 0; sdex < sticks; sdex++ {
-            axes := js.GetNumAxes(sdex)
-            sname := js.GetStickName(sdex)
-            sfname := js.GetStickFlagsName(sdex)
+            axes := js.NumAxes(sdex)
+            sname := js.StickName(sdex)
+            sfname := js.StickFlagsName(sdex)
             t.Logf("Stick %s (nr %d, %s) has %d axes: ", sname, sdex, sfname, axes)
             for adex := 0; adex < axes; adex++ {
-                aname := js.GetAxisName(sdex, adex)
+                aname := js.AxisName(sdex, adex)
                 t.Logf("%s (nr %d) ", aname, adex)
             }
         }
         t.Logf("\nButtons :")
         for bdex := 0; bdex < buttons; bdex++ {
-            bname := js.GetButtonName(bdex)
+            bname := js.ButtonName(bdex)
             t.Logf("%s (nr %d) ", bname, bdex)
         }
         t.Logf("\n")
@@ -240,7 +240,7 @@ func TestDisplayMode(t *testing.T) {
         t.Logf("Display mode: %s\n", m.String());
     }
     
-    monitors := GetAllMonitorInfo() 
+    monitors := AllMonitorInfo() 
     for _, m := range monitors {
         t.Logf("Monitor : %s\n", m.String());
     }

+ 42 - 36
al/bitmap.go

@@ -23,13 +23,19 @@ func (bmp *Bitmap) toC() * C.ALLEGRO_BITMAP {
 
 
 // Destroys a bitmap. Use this only when really needed!
-func (self *Bitmap) Destroy() {
-    if self.handle != nil {
-        C.al_destroy_bitmap(self.handle)
+func (bmp *Bitmap) Destroy() {
+    if bmp.handle != nil {
+        C.al_destroy_bitmap(bmp.handle)
     }
-    self.handle = nil
+    bmp.handle = nil
 }
 
+// Alias for destoy to make this implement a Closer interface
+func (bmp *Bitmap) Close() {
+    bmp.Destroy()
+}
+
+
 // Wraps a C Allegro bitmap in a Bitmap. Sets no finalizer.
 func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
     if handle == nil {
@@ -40,11 +46,11 @@ func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
 
 // Wraps a C Allegro Bitmap in a Bitmap. Sets a finalizer that calls Destroy.
 func wrapBitmap(handle *C.ALLEGRO_BITMAP) *Bitmap {
-    self := wrapBitmapRaw(handle)
-    if self != nil {
-        runtime.SetFinalizer(self, func(me *Bitmap) { me.Destroy() })
+    bmp := wrapBitmapRaw(handle)
+    if bmp != nil {
+        runtime.SetFinalizer(bmp, func(me *Bitmap) { me.Destroy() })
     }
-    return self
+    return bmp
 }
 
 const (
@@ -75,23 +81,23 @@ func AddNewBitmapFlag(flags int) {
 }
 
 // Gets the format for new bitmaps that are created using CreateBitmap
-func NewBitmapFormat(format int) int {
+func NewBitmapFormat() int {
     return int(C.al_get_new_bitmap_format())
 }
 
 // Gets the flags for new bitmaps that are created using CreateBitmap
-func NewBitmapFlags(flags int) int {
+func NewBitmapFlags() int {
     return int(C.al_get_new_bitmap_flags())
 }
 
 // Gets the width of the bitmap.
-func (self *Bitmap) Width() int {
-    return int(C.al_get_bitmap_width(self.handle))
+func (bmp *Bitmap) Width() int {
+    return int(C.al_get_bitmap_width(bmp.handle))
 }
 
 // Gets the height of the bitmap.
-func (self *Bitmap) Height() int {
-    return int(C.al_get_bitmap_height(self.handle))
+func (bmp *Bitmap) Height() int {
+    return int(C.al_get_bitmap_height(bmp.handle))
 }
 
 // Gets the width of the bitmap as a float32.
@@ -107,13 +113,13 @@ func (bmp *Bitmap) Heightf() float32 {
 
 
 // Gets the format of the bitmap.
-func (self *Bitmap) Format() int {
-    return int(C.al_get_bitmap_format(self.handle))
+func (bmp *Bitmap) Format() int {
+    return int(C.al_get_bitmap_format(bmp.handle))
 }
 
 // Gets the flags of the bitmap.
-func (self *Bitmap) Flags() int {
-    return int(C.al_get_bitmap_flags(self.handle))
+func (bmp *Bitmap) Flags() int {
+    return int(C.al_get_bitmap_flags(bmp.handle))
 }
 
 // Creates a new RAW bitmap. It will not be automatically destroyed!
@@ -138,14 +144,14 @@ func PutBlendedPixel(x, y int, color Color) {
 }
 
 // Gets a pixel from the bitmap
-func (self *Bitmap) GetPixel(x, y int) (color Color) {
-    return wrapColor(C.al_get_pixel(self.handle, C.int(x), C.int(y)))
+func (bmp *Bitmap) Pixel(x, y int) (color Color) {
+    return wrapColor(C.al_get_pixel(bmp.handle, C.int(x), C.int(y)))
 }
 
 // Converts pixels of the mask color to transparent pixels (with an alpha channel) 
 // for the given bitmap. Useful for, say "magic pink" backgrounds.
-func (self *Bitmap) ConvertMaskToAlpha(mask_color Color) {
-    C.al_convert_mask_to_alpha(self.handle, mask_color.toC())
+func (bmp *Bitmap) ConvertMaskToAlpha(mask_color Color) {
+    C.al_convert_mask_to_alpha(bmp.handle, mask_color.toC())
 }
 
 // Sets the clipping rectangle for the currently active bitmap. Anything drawn outside
@@ -168,29 +174,29 @@ func ClippingRectangle() (x, y, w, h int) {
 
 // Creates a RAW sub bitmap of the given bitmap that must be manually destoyed with 
 // Destroy() 
-func (self *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
-    return wrapBitmapRaw(C.al_create_sub_bitmap(self.handle,
+func (bmp *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
+    return wrapBitmapRaw(C.al_create_sub_bitmap(bmp.handle,
         C.int(x), C.int(y), C.int(w), C.int(h)))
 }
 
 // Creates a sub bitmap of the given bitmap that will automatically be destoyed
 // through a finalizer. However, you must ensure that this destroy happens before the 
 // parent bitmap is disposed of. You may need to call Destroy manyally anyway. 
-func (self *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
-    return wrapBitmap(C.al_create_sub_bitmap(self.handle,
+func (bmp *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
+    return wrapBitmap(C.al_create_sub_bitmap(bmp.handle,
         C.int(x), C.int(y), C.int(w), C.int(h)))
 }
 
 // Returns whether or not the bitmap is a sub bitmap 
-func (self *Bitmap) IsSubBitmap() bool {
-    return cb2b(C.al_is_sub_bitmap(self.handle))
+func (bmp *Bitmap) IsSubBitmap() bool {
+    return cb2b(C.al_is_sub_bitmap(bmp.handle))
 }
 
 // Returns the parent bitmap of this sub bitmap, or nil if there is no parent. 
 // This is a raw bitmap that has no finaliser set on it since likely 
 /// this function will only be used for inspection.
-func (self *Bitmap) Parent() *Bitmap {
-    return wrapBitmapRaw(C.al_get_parent_bitmap(self.handle))
+func (bmp *Bitmap) Parent() *Bitmap {
+    return wrapBitmapRaw(C.al_get_parent_bitmap(bmp.handle))
 }
 
 // Gets the Returns the X position within the parent of a sub bitmap
@@ -209,19 +215,19 @@ func (bmp *Bitmap) Reparent(parent * Bitmap, x, y, w, h int) {
 
 // Returns a raw clone of the bitmap, that will not be automatically 
 // destroyed.
-func (self *Bitmap) CloneRaw() *Bitmap {
-    return wrapBitmapRaw(C.al_clone_bitmap(self.handle))
+func (bmp *Bitmap) CloneRaw() *Bitmap {
+    return wrapBitmapRaw(C.al_clone_bitmap(bmp.handle))
 }
 
 // Returns a clone of the bitmap, that will automatically be
 // destroyed.
-func (self *Bitmap) Clone() *Bitmap {
-    return wrapBitmap(C.al_clone_bitmap(self.handle))
+func (bmp *Bitmap) Clone() *Bitmap {
+    return wrapBitmap(C.al_clone_bitmap(bmp.handle))
 }
 
 // Converts the bitmap to the current screen format, to ensure the blitting goes fast
-func (self *Bitmap) Convert() {
-    C.al_convert_bitmap(self.handle)
+func (bmp *Bitmap) Convert() {
+    C.al_convert_bitmap(bmp.handle)
 }
 
 // Converts all known unconverted memory bitmaps to the current screen format, 

+ 3 - 3
al/blender.go

@@ -56,7 +56,7 @@ func SetBlendColor(color Color) {
     C.al_set_blend_color(color.toC())
 }
 
-func GetBlender() (op BlendOperations, src, dest BlendMode) {
+func Blender() (op BlendOperations, src, dest BlendMode) {
     var cop, csrc, cdest C.int
     C.al_get_blender(&cop, &csrc, &cdest)
     op   = BlendOperations(cop)
@@ -65,7 +65,7 @@ func GetBlender() (op BlendOperations, src, dest BlendMode) {
     return op, src, dest
 }
 
-func GetBlendColor() Color {
+func BlendColor() Color {
     return wrapColor(C.al_get_blend_color())
 }
 
@@ -76,7 +76,7 @@ func SetSeparateBlender(op BlendOperations, src, dest BlendMode,
         C.int(alpha_op), C.int(alpha_src), C.int(alpha_dest))
 }
 
-func GetSeparateBlender() (op BlendOperations, src, dest BlendMode, 
+func SeparateBlender() (op BlendOperations, src, dest BlendMode, 
     alpha_op BlendOperations, alpha_src, alpha_dest BlendMode) {
     var cop, csrc, cdest, calpha_op, calpha_src, calpha_dest C.int
     C.al_get_separate_blender(&cop, &csrc, &cdest,

+ 20 - 10
al/display.go

@@ -215,6 +215,16 @@ func (self *Display) Height() int {
     return int(C.al_get_display_height(self.handle))
 }
 
+// Gets the width of the display in float32
+func (self *Display) Widthf() float32 {
+    return float32(self.Width())
+}
+
+// Gets the height of the display in float32
+func (self *Display) Heightf() float32 {
+    return float32(self.Height())
+}
+
 // Gets the refresh rate of the display
 func (self *Display) RefreshRate() int {
     return int(C.al_get_display_refresh_rate(self.handle))
@@ -246,7 +256,7 @@ func setTargetCBitmap(bmp *C.ALLEGRO_BITMAP) {
 }
 
 // Sets the target bitmap of the allegro drawing
-func SetTargetBitmap(bmp Bitmap) {
+func SetTargetBitmap(bmp *Bitmap) {
     setTargetCBitmap(bmp.handle)
 }
 
@@ -290,9 +300,9 @@ func WaitForVsync() {
     C.al_wait_for_vsync()
 }
 
-// Gets the event source of the display to registeron an event queue 
+// Gets the event source of the display to register on an event queue 
 // with RegisterEventSource.
-func (self *Display) GetEventSource() *EventSource {
+func DisplayEventSource(self * Display) *EventSource {
     return wrapEventSourceRaw(C.al_get_display_event_source(self.handle))
 }
 
@@ -339,15 +349,15 @@ func (self *MonitorInfo) toC() *C.ALLEGRO_MONITOR_INFO {
     return (*C.ALLEGRO_MONITOR_INFO)(self)
 }
 
-// Gets the monitor info for the index'th video adapter
-func (self *MonitorInfo) Get(index int) bool {
+// Finds the monitor info for the index'th video adapter
+func (self *MonitorInfo) Find(index int) bool {
     return cb2b(C.al_get_monitor_info(C.int(index), self.toC()))
 }
 
-// Gets the monitor info for the index'th video adapter
-func GetMonitorInfo(index int) *MonitorInfo {
+// Finds the monitor info for the index'th video adapter
+func FindMonitorInfo(index int) *MonitorInfo {
     var info MonitorInfo
-    if (&info).Get(index) {
+    if (&info).Find(index) {
         return &info
     }
     return nil
@@ -358,11 +368,11 @@ func (mi * MonitorInfo) String() string {
 }
 
 // Gets all available monitors and their info
-func GetAllMonitorInfo() []*MonitorInfo {
+func AllMonitorInfo() []*MonitorInfo {
     count := NumVideoAdapters();
     info := make([]*MonitorInfo, count)
     for i := 0 ; i < count; i ++ {
-        info[i] = GetMonitorInfo(i)
+        info[i] = FindMonitorInfo(i)
     }
     return info
 }

+ 36 - 9
al/event.go

@@ -131,6 +131,11 @@ type TouchEvent     C.ALLEGRO_TOUCH_EVENT
 type UserEvent      C.ALLEGRO_USER_EVENT
 
 
+func (ev JoystickEvent        ) MarkJoystick()  { ; }
+func (ev KeyboardEvent        ) MarkKey()       { ; }
+func (ev MouseEvent           ) MarkMouse()     { ; }
+func (ev DisplayEvent         ) MarkDisplay() { ; }
+func (ev TouchEvent           ) MarkTouch() { ; }             
 
 // Converts wrapper EventUnion pointer to C Allegro event pointer
 func (self *EventUnion) toC() *C.ALLEGRO_EVENT {
@@ -142,8 +147,11 @@ func (self *EventUnion) toPointer() unsafe.Pointer {
     return unsafe.Pointer(self.toC())
 }
 
+func (self *EventUnion) toUP() unsafe.Pointer {
+    return unsafe.Pointer(self.toC())
+}
 
-// Converts wrapper EventUnion pointer to an EventUnion interface struct
+// Converts wrapper EventUnion pointer to an Event interface struct
 func (evun *EventUnion) Event() Event {
     ae := (*C.ALLEGRO_ANY_EVENT)(evun.toPointer())
     switch (C.int(ae._type)) {
@@ -156,7 +164,7 @@ func (evun *EventUnion) Event() Event {
         case EVENT_KEY_DOWN                 : fallthrough
         case EVENT_KEY_UP                   : 
             return (*KeyboardEvent)(evun.toPointer())
-
+ 
         case EVENT_MOUSE_AXES               : fallthrough    
         case EVENT_MOUSE_BUTTON_DOWN        : fallthrough    
         case EVENT_MOUSE_BUTTON_UP          : fallthrough    
@@ -177,6 +185,12 @@ func (evun *EventUnion) Event() Event {
         case EVENT_DISPLAY_SWITCH_OUT       : fallthrough    
         case EVENT_DISPLAY_ORIENTATION      :
             return (*DisplayEvent)(evun.toPointer())
+
+        case EVENT_TOUCH_BEGIN              : fallthrough
+        case EVENT_TOUCH_MOVE               : fallthrough
+        case EVENT_TOUCH_CANCEL             : fallthrough
+        case EVENT_TOUCH_END                :
+            return (*TouchEvent)(evun.toPointer())        
         default: break
     }
     
@@ -189,7 +203,6 @@ func (evun *EventUnion) Event() Event {
 
 /* These wrappers implement the interface Event for all event types */
 
-
 func (ev AnyEvent     ) Type() int { return int(ev._type); }
 func (ev DisplayEvent ) Type() int { return int(ev._type); }
 func (ev JoystickEvent) Type() int { return int(ev._type); }
@@ -309,6 +322,20 @@ func (de DisplayEvent) Orientation() int {
     return int(de.orientation)
 }
 
+// Returns the ID of the joystick for the joystick event.
+func (je JoystickEvent) ID() int {
+    jsptr := je.id
+    for i := 0 ; i < NumJoysticks() ; i++ {
+        js := FindJoystick(i)
+        if js.handle == jsptr {
+            return i
+        }
+    }
+    /* shouln't happen, but... */
+    return 0xbad101
+}
+
+
 // Returns the stick number of the joystick event.
 func (je JoystickEvent) Stick() int {
     return int(je.stick)
@@ -324,9 +351,9 @@ func (je JoystickEvent) Button() int {
     return int(je.button)
 }
 
-// Returns the position of the joystick event.
-func (je JoystickEvent) Pos() int {
-    return int(je.pos)
+// Returns the position of the joystick axis during the event.
+func (je JoystickEvent) Pos() float32 {
+    return float32(je.pos)
 }
 
 // Returns the display that has emitted the keyboard event.
@@ -335,7 +362,7 @@ func (ke KeyboardEvent) Display() *Display {
 }
 
 // Returns the key code of the keyboard event. 
-func (ke KeyboardEvent) Keycode() int {
+func (ke KeyboardEvent) KeyCode() int {
     return int(ke.keycode)
 }
 
@@ -451,7 +478,7 @@ func (te TouchEvent) DY() int {
     return int(te.dy)
 }
 
-/* The safest way to use user events from GO is to use integer handles
+/* The safest way to use user events from Go is to use integer handles
  * as offsets into a GO-allocated map. */
 
 func (ue UserEvent) Data1Pointer() unsafe.Pointer { return unsafe.Pointer(uintptr(ue.data1));}
@@ -535,7 +562,7 @@ func (self *EventQueue) IsEmpty() bool {
 
 // Returns the next event from the event queue as well as a bool
 // to signify if an event was fetched sucessfully or not.
-func (self *EventQueue) GetNextEvent() (event *EventUnion, ok bool) {
+func (self *EventQueue) NextEvent() (event *EventUnion, ok bool) {
     event = &EventUnion{}
     ok = bool(C.al_get_next_event(self.handle, event.toC()))
     return event, ok

+ 7 - 2
al/font.go

@@ -40,6 +40,11 @@ func (self *Font) Destroy() {
     self.handle = nil
 }
 
+//Alias for Destroy, to make fonts implement the Closer interface
+func (font *Font) Close() {
+    font.Destroy()
+}
+
 // Wraps a C font into a go font
 func wrapFontRaw(data *C.ALLEGRO_FONT) *Font {
     if data == nil {
@@ -277,7 +282,7 @@ func ShutdownFontAddon() {
 }
 
 // Gets the allegro font addon version
-func GetAllegroFontVersion() uint32 {
+func AllegroFontVersion() uint32 {
     return (uint32)(C.al_get_allegro_font_version())
 }
 
@@ -354,7 +359,7 @@ func (font * Font) GlyphDimensions(color Color, cp int) (ok bool, bbx, bby, bbw,
 
 
 /*
-The fallback is a hassle, might be better to do this in Go.
+The callback is a hassle, might be better to do this in Go.
 ALLEGRO_FONT_FUNC(void, al_do_multiline_text, (const ALLEGRO_FONT *font,
    float max_width, const char *text,
    bool (*cb)(int line_num, const char *line, int size, void *extra),

+ 4 - 4
al/image.go

@@ -14,16 +14,16 @@ import "C"
 
 // Initializes the image format addon
 func InitImageAddon() bool {
-	return cb2b(C.al_init_image_addon())
+    return cb2b(C.al_init_image_addon())
 }
 
 // Shuts down the image format addon
 func ShutdownImageAddon() {
-	C.al_shutdown_image_addon()
+    C.al_shutdown_image_addon()
 }
 
 // Returns the version of the image loading addon.
 // Gets the allegro font addon version
-func GetAllegroImageVersion() uint32 {
-	return (uint32)(C.al_get_allegro_image_version())
+func AllegroImageVersion() uint32 {
+    return (uint32)(C.al_get_allegro_image_version())
 }

+ 16 - 16
al/joystick.go

@@ -53,7 +53,7 @@ func (self *JoystickState) toC() *C.ALLEGRO_JOYSTICK_STATE {
 // Gets the state of the axis for the given stick on the joystick.
 // returns 0.0 if the stick or axis are out of range. May return
 // garbage for nonexisting sticks and axes.
-func (self *JoystickState) GetStickAxis(stick, axis int) float32 {
+func (self *JoystickState) StickAxis(stick, axis int) float32 {
     if stick >= int(C._AL_MAX_JOYSTICK_STICKS) {
         return 0.0
     }
@@ -71,7 +71,7 @@ func (self *JoystickState) GetStickAxis(stick, axis int) float32 {
 
 // Gerts the state of the button with the given index on the joystick.
 // Will return -1 if the button is out of range.
-func (self *JoystickState) GetButton(button int) int {
+func (self *JoystickState) Button(button int) int {
     if button >= int(C._AL_MAX_JOYSTICK_BUTTONS) {
         return -1
     }
@@ -103,12 +103,12 @@ func IsJoystickInstalled() bool {
 }
 
 // Returns the amount of joysticks detected.
-func GetNumJoysticks() int {
+func NumJoysticks() int {
     return int(C.al_get_num_joysticks())
 }
 
 // Returns the joyn'th joystick, or nil if no such stick exists. 
-func GetJoystick(joyn int) *Joystick {
+func FindJoystick(joyn int) *Joystick {
     return wrapJoystick(C.al_get_joystick(C.int(joyn)))
 }
 
@@ -120,37 +120,37 @@ func (self *Joystick) IsActive() bool {
 }
 
 // Returns the name of the joystick self.
-func (self *Joystick) GetName() string {
+func (self *Joystick) Name() string {
     return gostr(C.al_get_joystick_name(self.handle))
 }
 
 // Returns the amount of sticks the joystick self has.
-func (self *Joystick) GetNumSticks() int {
+func (self *Joystick) NumSticks() int {
     return int(C.al_get_joystick_num_sticks(self.handle))
 }
 
 // Returns the joystick flags for the numbered stick on the joystick self.
-func (self *Joystick) GetStickFlags(stick int) int {
+func (self *Joystick) StickFlags(stick int) int {
     return int(C.al_get_joystick_stick_flags(self.handle, C.int(stick)))
 }
 
 // Returns true if the numbered stick on joystick self is digital, false if not.
 // Note that theoretically, a stick could be both digital and analog...
 func (self *Joystick) IsStickDigital(stick int) bool {
-    return (JOYFLAG_DIGITAL & self.GetStickFlags(stick)) == JOYFLAG_DIGITAL
+    return (JOYFLAG_DIGITAL & self.StickFlags(stick)) == JOYFLAG_DIGITAL
 }
 
 // Returns true if the numbered stick on joystick self is analog, false if not
 // Note that theoretically, a stick could be both digital and analog...
 func (self *Joystick) IsStickAnalog(stick int) bool {
-    return (JOYFLAG_ANALOGUE & self.GetStickFlags(stick)) == JOYFLAG_ANALOGUE
+    return (JOYFLAG_ANALOGUE & self.StickFlags(stick)) == JOYFLAG_ANALOGUE
 }
 
 // Returns a string that describes the joystick flags for the numbered stick 
 // on the joystick self. Will return "Analog" for an analog joystick, 
 // "Digital" for a digital joystick, "Hybrid" fo one that's both and 
 // "None" for one that's neither
-func (self *Joystick) GetStickFlagsName(stick int) string {
+func (self *Joystick) StickFlagsName(stick int) string {
     if self.IsStickAnalog(stick) {
         if self.IsStickDigital(stick) {
             return "Hybrid"
@@ -165,32 +165,32 @@ func (self *Joystick) GetStickFlagsName(stick int) string {
 }
 
 // Returns the name of the stick on the joystick self.
-func (self *Joystick) GetStickName(stick int) string {
+func (self *Joystick) StickName(stick int) string {
     return gostr(C.al_get_joystick_stick_name(self.handle, C.int(stick)))
 }
 
 // Returns the amount of axes for the stick on the joystick self.
-func (self *Joystick) GetNumAxes(stick int) int {
+func (self *Joystick) NumAxes(stick int) int {
     return int(C.al_get_joystick_num_axes(self.handle, C.int(stick)))
 }
 
 // Returns the name of the axis for the stick on the joystick self.
-func (self *Joystick) GetAxisName(stick, axis int) string {
+func (self *Joystick) AxisName(stick, axis int) string {
     return gostr(C.al_get_joystick_axis_name(self.handle, C.int(stick), C.int(axis)))
 }
 
 // Returns the amount of buttons on the joystick self.
-func (self *Joystick) GetNumButtons() int {
+func (self *Joystick) NumButtons() int {
     return int(C.al_get_joystick_num_buttons(self.handle))
 }
 
 // Returns the name of the button on the joystick self.
-func (self *Joystick) GetButtonName(button int) string {
+func (self *Joystick) ButtonName(button int) string {
     return gostr(C.al_get_joystick_button_name(self.handle, C.int(button)))
 }
 
 // Gets the state of the joystick
-func (self *Joystick) GetState() *JoystickState {
+func (self *Joystick) State() *JoystickState {
     state := &JoystickState{}
     C.al_get_joystick_state(self.handle, state.toC())
     return state

+ 2 - 2
al/keyboard.go

@@ -48,7 +48,7 @@ func SetKeyboardLeds(leds int) bool {
 
 // Returns the Keyboard event source that can be registered to an EventQueue
 // with RegisterEventSource.
-func GetKeyboardEventSource() *EventSource {
+func KeyboardEventSource() *EventSource {
     return (*EventSource)(C.al_get_keyboard_event_source())
 }
 
@@ -231,7 +231,7 @@ func (ks * KeyboardState) toC() * C.ALLEGRO_KEYBOARD_STATE {
 }
 
 
-func GetKeyboardState() * KeyboardState {
+func PollKeyboardState() * KeyboardState {
     ks := &KeyboardState{}
     C.al_get_keyboard_state(ks.toC());
     return ks

+ 7 - 7
al/memfile.go

@@ -15,15 +15,15 @@ import "unsafe"
 
 // Returns the version of the image loading addon.
 // Gets the allegro font addon version
-func GetAllegroMemfileVersion() uint32 {
-	return (uint32)(C.al_get_allegro_memfile_version())
+func AllegroMemfileVersion() uint32 {
+    return (uint32)(C.al_get_allegro_memfile_version())
 }
 
 // Opens a memfile. Data can be put in a buffer and given to Allegro.
 func OpenMemfile(buffer []byte, mode string) *File {
-	cmode := cstr(mode)
-	defer cstrFree(cmode)
-	csize := C.int64_t(len(buffer))
-	cmem := unsafe.Pointer(&buffer[0])
-	return wrapFile(C.al_open_memfile(cmem, csize, cmode))
+    cmode := cstr(mode)
+    defer cstrFree(cmode)
+    csize := C.int64_t(len(buffer))
+    cmem := unsafe.Pointer(&buffer[0])
+    return wrapFile(C.al_open_memfile(cmem, csize, cmode))
 }

+ 2 - 2
al/mode.go

@@ -43,7 +43,7 @@ func NumDisplayModes() int {
     return int(C.al_get_num_display_modes())
 }
 
-func GetDisplayMode(index int) (disp * DisplayMode) {
+func FindDisplayMode(index int) (disp * DisplayMode) {
     disp = &DisplayMode{}
     if nil == C.al_get_display_mode(C.int(index), disp.toC()) {
         return nil
@@ -55,7 +55,7 @@ func DisplayModes() (modes [] *DisplayMode) {
     count := NumDisplayModes()
     modes = make([]*DisplayMode, count)
     for i:=0 ; i < count ; i ++ {
-        modes[i] = GetDisplayMode(i)
+        modes[i] = FindDisplayMode(i)
     }
     return modes
 }

+ 5 - 5
al/mouse.go

@@ -163,11 +163,11 @@ func UninstallMouse() {
     C.al_uninstall_mouse()
 }
 
-func GetMouseNumButtons() uint {
+func MouseNumButtons() uint {
     return uint(C.al_get_mouse_num_buttons())
 }
 
-func GetMouseNumAxes() uint {
+func MouseNumAxes() uint {
     return uint(C.al_get_mouse_num_axes())
 }
 
@@ -187,7 +187,7 @@ func SetMouseAxis(axis, value int) bool {
     return cb2b(C.al_set_mouse_axis(ci(axis), ci(value)))
 }
 
-func AlGetMouseState() MouseState {
+func PollMouseState() MouseState {
     var state C.ALLEGRO_MOUSE_STATE
     C.al_get_mouse_state(&state)
     return wrapMouseState(state)
@@ -201,7 +201,7 @@ func (state * MouseState) Axis(axis int) int {
     return int(C.al_get_mouse_state_axis(state.toCPointer(), ci(axis)))
 }
 
-func GetMouseEventSource() * EventSource {
+func MouseEventSource() * EventSource {
     return wrapEventSourceRaw(C.al_get_mouse_event_source())
 }
 
@@ -229,7 +229,7 @@ func (display * Display) HideMouseCursor() bool {
     return cb2b(C.al_hide_mouse_cursor(display.toC()))
 }
 
-func GetMouseCursorPosition() (ok bool, x, y int) {
+func MouseCursorPosition() (ok bool, x, y int) {
     var cx, cy C.int
     ok = cb2b(C.al_get_mouse_cursor_position(&cx, &cy))
     x = int(cx)

+ 8 - 1
al/primitives.go

@@ -196,7 +196,7 @@ type IndexBuffer struct {
     handle * C.ALLEGRO_INDEX_BUFFER
 }
 
-func GetPrimitivesVersion() uint32 {
+func PrimitivesVersion() uint32 {
     return uint32(C.al_get_allegro_primitives_version())
 }
 
@@ -463,6 +463,13 @@ func DrawFilledRectangle(x1, y1, x2, y2 float32, color Color) {
                    color.toC())
 } 
 
+func DrawFilledRectangleInt(x1, y1, x2, y2 int, color Color) {
+    C.al_draw_filled_rectangle(C.float(x1), C.float(y1), 
+                   C.float(x2), C.float(y2), 
+                   color.toC())
+} 
+
+
 
 func DrawFilledRoundedRectangle(x1, y1, x2, y2, rx, ry float32, color Color) {
     C.al_draw_filled_rounded_rectangle(C.float(x1), C.float(y1), 

+ 1 - 1
al/shader.go

@@ -160,7 +160,7 @@ func (sh * Shader) SetFloatVector(name string, nc int, f []float32) bool {
 }
 
 
-func GetDefaultShaderSource(pla ShaderPlatform, ty ShaderType) string {
+func DefaultShaderSource(pla ShaderPlatform, ty ShaderType) string {
     return C.GoString(C.al_get_default_shader_source(pla.toC(), ty.toC()))
 }
 

+ 2 - 2
al/touch_input.go

@@ -60,13 +60,13 @@ func UninstallTouchInput() {
     C.al_uninstall_touch_input()
 }
 
-func GetTouchInputState() TouchInputState {
+func PollTouchInputState() TouchInputState {
     cstate := C.struct_ALLEGRO_TOUCH_INPUT_STATE{}
     C.al_get_touch_input_state(&cstate)
     return wrapTouchInputStateRaw(cstate)
 }
 
-func GetTouchInputEventSource() * EventSource {
+func TouchInputEventSource() * EventSource {
     return wrapEventSourceRaw(C.al_get_touch_input_event_source())
 }
 

+ 12 - 0
al/transformations.go

@@ -90,6 +90,12 @@ func (trans * Transform) Translate(x, y float32) * Transform {
     return trans
 }
 
+func (trans * Transform) TranslateInt(x, y int) * Transform {
+    C.al_translate_transform(trans.toC(), C.float(x), C.float(y))
+    return trans
+}
+
+
 func (trans * Transform) Translate3D(x, y, z float32) * Transform {
     C.al_translate_transform_3d(trans.toC(), C.float(x), C.float(y), C.float(z))
     return trans
@@ -112,6 +118,12 @@ func (trans * Transform) Scale(x, y float32) * Transform {
     return trans
 }
 
+func (trans * Transform) ScaleInt(x, y int) * Transform {
+    C.al_scale_transform(trans.toC(), C.float(x), C.float(y))
+    return trans
+}
+
+
 func (trans * Transform) Scale3D(x, y, z float32) * Transform {
     C.al_scale_transform_3d(trans.toC(), C.float(x), C.float(y), C.float(z))
     return trans

+ 1 - 0
go.mod

@@ -0,0 +1 @@
+module gitlab.com/beoran/al5go

+ 15 - 0
mainthread/mainthread.go

@@ -0,0 +1,15 @@
+package mainthread
+
+import "runtime"
+
+func Run(Main func()) {
+    runtime.LockOSThread()
+    Main()
+    runtime.UnlockOSThread()
+}
+
+
+
+
+
+

+ 0 - 0
pkg/.gitkeep


+ 55 - 0
tool/gentype

@@ -0,0 +1,55 @@
+#!/usr/bin/env ruby
+
+TEMPLATE=<<EOT
+type XXX struct {
+    handle * C.YYY
+}
+
+// Converts a zzz to it's underlying C pointer
+func (self * XXX) toC() *C.YYY {
+    return (*C.YYY)(self.handle)
+}
+
+// Destroys the zzz.
+func (self *XXX) Destroy() {
+    if self.handle != nil {
+        C.al_destroy_zzz(self.toC())
+    }
+    self.handle = nil
+}
+
+// Wraps a C zzz into a go zzz
+func wrapXXXRaw(data *C.YYY) *XXX {
+    if data == nil {
+        return nil
+    }
+    return &XXX{data}
+}
+
+// Sets up a finalizer for this XXX that calls Destroy()
+func (self *XXX) SetDestroyFinalizer() *XXX {
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *XXX) { me.Destroy() })
+    }
+    return self
+}
+
+// Wraps a C zzz into a go zzz and sets up a finalizer that calls Destroy()
+func wrapXXX(data *C.YYY) *XXX {
+    self := wrapXXXRaw(data)
+    return self.SetDestroyFinalizer()
+}
+EOT
+
+
+gotype      = ARGV[0] || 'XXX'
+ctype       = ARGV[1] || 'YYY'
+funcname    = ARGV[2] || 'zzz' 
+
+
+res = TEMPLATE.gsub('XXX', gotype).gsub('YYY',ctype).gsub('zzz', funcname)
+
+puts res
+
+
+