2017-10-03 18:38:09 +00:00
|
|
|
package allegro5
|
|
|
|
|
|
|
|
// #include <allegro5/allegro.h>
|
|
|
|
// #include <allegro5/allegro_font.h>
|
|
|
|
// #include <allegro5/allegro_image.h>
|
|
|
|
// #include <allegro5/allegro_primitives.h>
|
|
|
|
// #include <allegro5/allegro_ttf.h>
|
|
|
|
// bool init() {
|
|
|
|
// return al_init();
|
|
|
|
// }
|
|
|
|
import "C"
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type InitConfig struct {
|
|
|
|
Font bool
|
|
|
|
Image bool
|
|
|
|
Primitives bool
|
|
|
|
Keyboard bool
|
|
|
|
Mouse bool
|
|
|
|
}
|
|
|
|
|
2018-02-10 08:13:35 +00:00
|
|
|
var InitAll = InitConfig{true, true, true, true, true}
|
|
|
|
|
2017-10-03 18:38:09 +00:00
|
|
|
// Init initializes the Allegro system
|
|
|
|
func Init(config InitConfig) error {
|
|
|
|
if !bool(C.init()) {
|
|
|
|
return fmt.Errorf("Failed to initialize Allegro")
|
|
|
|
}
|
|
|
|
if config.Font && !bool(C.al_init_font_addon()) {
|
|
|
|
return fmt.Errorf("Failed to initialize font addon")
|
|
|
|
}
|
|
|
|
if config.Font && !bool(C.al_init_ttf_addon()) {
|
|
|
|
return fmt.Errorf("Failed to initialize ttf addon")
|
|
|
|
}
|
|
|
|
if config.Image && !bool(C.al_init_image_addon()) {
|
|
|
|
return fmt.Errorf("Failed to initialize image addon")
|
|
|
|
}
|
|
|
|
if config.Primitives && !bool(C.al_init_primitives_addon()) {
|
|
|
|
return fmt.Errorf("Failed to initialize primitives addon")
|
|
|
|
}
|
|
|
|
if config.Keyboard && !bool(C.al_install_keyboard()) {
|
|
|
|
return fmt.Errorf("Failed to install keyboard")
|
|
|
|
}
|
|
|
|
if config.Mouse && !bool(C.al_install_mouse()) {
|
|
|
|
return fmt.Errorf("Failed to install mouse")
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|