memfile.go 775 B

1234567891011121314151617181920212223242526272829
  1. // Memfile extension
  2. package al
  3. /*
  4. #cgo pkg-config: allegro_memfile-5
  5. #cgo CFLAGS: -I/usr/local/include
  6. #cgo linux LDFLAGS: -lc_nonshared
  7. #include <stdlib.h>
  8. #include <allegro5/allegro.h>
  9. #include <allegro5/allegro_memfile.h>
  10. #include "helpers.h"
  11. */
  12. import "C"
  13. import "unsafe"
  14. // Returns the version of the image loading addon.
  15. // Gets the allegro font addon version
  16. func AllegroMemfileVersion() uint32 {
  17. return (uint32)(C.al_get_allegro_memfile_version())
  18. }
  19. // Opens a memfile. Data can be put in a buffer and given to Allegro.
  20. func OpenMemfile(buffer []byte, mode string) *File {
  21. cmode := cstr(mode)
  22. defer cstrFree(cmode)
  23. csize := C.int64_t(len(buffer))
  24. cmem := unsafe.Pointer(&buffer[0])
  25. return wrapFile(C.al_open_memfile(cmem, csize, cmode))
  26. }