Rally X
ELEN3009 Project by Justin Wernick and David Schneider
|
00001 #include "AllegroWrappers.h" 00002 00003 int AllegroInit::_initCount = 0; 00004 00005 AllegroInit::AllegroInit() 00006 { 00007 if (_initCount==0) 00008 { 00009 if (!al_init()) 00010 { 00011 throw InstallFailure(); 00012 } 00013 } 00014 ++_initCount; 00015 } 00016 00017 AllegroInit::AllegroInit(const AllegroInit& ref) 00018 { 00019 if (_initCount==0) 00020 { 00021 if (!al_init()) 00022 { 00023 throw InstallFailure(); 00024 } 00025 } 00026 ++_initCount; 00027 } 00028 00029 AllegroInit::~AllegroInit() 00030 { 00031 --_initCount; 00032 if (_initCount==0) 00033 { 00034 al_uninstall_system(); 00035 } 00036 } 00037 00038 00039 int AllegroKeyboardInit::_initCount = 0; 00040 00041 AllegroKeyboardInit::AllegroKeyboardInit() 00042 { 00043 if (_initCount==0) 00044 { 00045 if (!al_install_keyboard()) 00046 { 00047 throw InstallFailure(); 00048 } 00049 } 00050 ++_initCount; 00051 } 00052 00053 AllegroKeyboardInit::AllegroKeyboardInit(const AllegroKeyboardInit& ref) 00054 { 00055 if (_initCount==0) 00056 { 00057 if (!al_install_keyboard()) 00058 { 00059 throw InstallFailure(); 00060 } 00061 } 00062 ++_initCount; 00063 } 00064 00065 AllegroKeyboardInit::~AllegroKeyboardInit() 00066 { 00067 --_initCount; 00068 if (_initCount==0) al_uninstall_keyboard(); 00069 } 00070 00071 int AllegroDrawingInit::_initCount = 0; 00072 00073 AllegroDrawingInit::AllegroDrawingInit() 00074 { 00075 if (_initCount==0) 00076 { 00077 if (!al_init_primitives_addon()) 00078 { 00079 throw InstallFailure(); 00080 } 00081 al_init_font_addon(); 00082 if (!al_init_ttf_addon()) 00083 { 00084 throw InstallFailure(); 00085 } 00086 } 00087 ++_initCount; 00088 } 00089 00090 AllegroDrawingInit::AllegroDrawingInit(const AllegroDrawingInit& ref) 00091 { 00092 if (_initCount==0) 00093 { 00094 if (!al_init_primitives_addon()) 00095 { 00096 throw InstallFailure(); 00097 } 00098 al_init_font_addon(); 00099 if (!al_init_ttf_addon()) 00100 { 00101 throw InstallFailure(); 00102 } 00103 } 00104 ++_initCount; 00105 } 00106 00107 AllegroDrawingInit::~AllegroDrawingInit() 00108 { 00109 --_initCount; 00110 if (_initCount==0) 00111 { 00112 al_shutdown_ttf_addon(); 00113 al_shutdown_font_addon(); 00114 al_shutdown_primitives_addon(); 00115 } 00116 }