sdlBase.cpp

00001 /*
00002   SDL の初期化
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include "sdlBase.h"
00008 #include <stdlib.h>
00009 #ifdef HAVE_CONFIG_H
00010 #include <config.h>
00011 #endif
00012 #if !HAVE_CONFIG_H || HAVE_LIBSDL
00013 #include <SDL.h>
00014 #endif
00015 
00016 
00017 bool SDL_Base::initialized = false;
00018 
00019 
00020 SDL_Base::SDL_Base(void) {
00021   sdl_initialize();
00022 }
00023 
00024 
00025 SDL_Base::~SDL_Base(void) {
00026 }
00027 
00028 
00029 void SDL_Base::sdl_initialize(void) {
00030 #if !HAVE_CONFIG_H || HAVE_LIBSDL
00031   if (!initialized) {
00032     if (SDL_Init(0) < 0) {
00033       throw SDL_Exception();
00034     }
00035     initialized = true;
00036     atexit(SDL_Quit);
00037   }
00038 #endif
00039 }
00040 
00041 
00042 const char* SDL_Exception::what(void) const throw() {
00043 #if !HAVE_CONFIG_H || HAVE_LIBSDL
00044   return SDL_GetError();
00045 #else
00046   return "SDL Library is not installed";
00047 #endif
00048 }
00049 

Generated on Mon Apr 13 22:52:05 2009 by  doxygen 1.5.7.1