From 98ba22e7064db57316dfff1ae127feb3dceeb73e Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 13:58:22 +0200 Subject: Initial commit --- source/logic/AllegroWrappers.cpp | 116 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 source/logic/AllegroWrappers.cpp (limited to 'source/logic/AllegroWrappers.cpp') 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(); + } +} -- cgit v1.2.3