summaryrefslogtreecommitdiff
path: root/source/logic/AllegroWrappers.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/logic/AllegroWrappers.cpp')
-rw-r--r--source/logic/AllegroWrappers.cpp116
1 files changed, 116 insertions, 0 deletions
diff --git a/source/logic/AllegroWrappers.cpp b/source/logic/AllegroWrappers.cpp
new file mode 100644
index 0000000..4094cfe
--- /dev/null
+++ b/source/logic/AllegroWrappers.cpp
@@ -0,0 +1,116 @@
+#include "AllegroWrappers.h"
+
+int AllegroInit::_initCount = 0;
+
+AllegroInit::AllegroInit()
+{
+ if (_initCount==0)
+ {
+ if (!al_init())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroInit::AllegroInit(const AllegroInit& ref)
+{
+ if (_initCount==0)
+ {
+ if (!al_init())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroInit::~AllegroInit()
+{
+ --_initCount;
+ if (_initCount==0)
+ {
+ al_uninstall_system();
+ }
+}
+
+
+int AllegroKeyboardInit::_initCount = 0;
+
+AllegroKeyboardInit::AllegroKeyboardInit()
+{
+ if (_initCount==0)
+ {
+ if (!al_install_keyboard())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroKeyboardInit::AllegroKeyboardInit(const AllegroKeyboardInit& ref)
+{
+ if (_initCount==0)
+ {
+ if (!al_install_keyboard())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroKeyboardInit::~AllegroKeyboardInit()
+{
+ --_initCount;
+ if (_initCount==0) al_uninstall_keyboard();
+}
+
+int AllegroDrawingInit::_initCount = 0;
+
+AllegroDrawingInit::AllegroDrawingInit()
+{
+ if (_initCount==0)
+ {
+ if (!al_init_primitives_addon())
+ {
+ throw InstallFailure();
+ }
+ al_init_font_addon();
+ if (!al_init_ttf_addon())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroDrawingInit::AllegroDrawingInit(const AllegroDrawingInit& ref)
+{
+ if (_initCount==0)
+ {
+ if (!al_init_primitives_addon())
+ {
+ throw InstallFailure();
+ }
+ al_init_font_addon();
+ if (!al_init_ttf_addon())
+ {
+ throw InstallFailure();
+ }
+ }
+ ++_initCount;
+}
+
+AllegroDrawingInit::~AllegroDrawingInit()
+{
+ --_initCount;
+ if (_initCount==0)
+ {
+ al_shutdown_ttf_addon();
+ al_shutdown_font_addon();
+ al_shutdown_primitives_addon();
+ }
+}