Browse Subversion Repository
Contents of /common/SdlInit.cpp
Parent Directory
| Revision Log
Revision 268 -
( show annotations)
( download)
( as text)
Sat Mar 8 03:22:09 2008 UTC
(16 years, 1 month ago)
by satofumi
File MIME type: text/x-c++src
File size: 812 byte(s)
SDL_win32 の include を削除
| 1 |
/*! |
| 2 |
\file |
| 3 |
\brief SDL の初期化クラス |
| 4 |
|
| 5 |
\author Satofumi KAMIMURA |
| 6 |
|
| 7 |
$Id$ |
| 8 |
*/ |
| 9 |
|
| 10 |
#include "SdlInit.h" |
| 11 |
#include "LogManager.h" |
| 12 |
#include <SDL.h> |
| 13 |
#include <stdlib.h> |
| 14 |
#include <string> |
| 15 |
|
| 16 |
using namespace beego; |
| 17 |
|
| 18 |
|
| 19 |
/*! |
| 20 |
\brief SdlInit の内部クラス |
| 21 |
*/ |
| 22 |
struct SdlInit::pImpl { |
| 23 |
static bool initialized; |
| 24 |
}; |
| 25 |
|
| 26 |
bool SdlInit::pImpl::initialized = false; |
| 27 |
|
| 28 |
|
| 29 |
SdlInit::SdlInit(void) : pimpl(new pImpl) { |
| 30 |
|
| 31 |
// !!! 問題が発生するようであれば、double lock にする |
| 32 |
|
| 33 |
if (pimpl->initialized == false) { |
| 34 |
if (SDL_Init(0) < 0) { |
| 35 |
// ログ記録 |
| 36 |
LogManager* log = LogManager::getObject(); |
| 37 |
std::string message = "SDL_Init(): " + std::string(SDL_GetError()); |
| 38 |
log->write(LogManager::Error, message.c_str()); |
| 39 |
throw; |
| 40 |
} |
| 41 |
atexit(SDL_Quit); |
| 42 |
pimpl->initialized = true; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
SdlInit::~SdlInit(void) { |
| 48 |
} |
|