sdlmanager.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 2005 by Tobias Nadler                                         */
00005 /*                                                                              */
00006 /*  This library is free software; you can redistribute it and/or               */
00007 /*  modify it under the terms of the GNU Lesser General Public                  */
00008 /*  License as published by the Free Software Foundation; either                */
00009 /*  version 2.1 of the License, or (at your option) any later version.          */
00010 /*                                                                              */
00011 /*  This library is distributed in the hope that it will be useful,             */
00012 /*  but WITHOUT ANY WARRANTY; without even the implied warranty of              */
00013 /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           */
00014 /*  Lesser General Public License for more details.                             */
00015 /*                                                                              */
00016 /*  You should have received a copy of the GNU Lesser General Public            */
00017 /*  License along with this library; if not, write to the Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
00019 /*                                                                              */
00020 /********************************************************************************/
00021 
00022 #ifndef SDLMANAGER_H
00023 #define SDLMANAGER_H
00024 
00025 #include "SDL/SDL.h"
00026 #include "tinyxml.h"
00027 #include <list>
00028 #include "sdlsurface.h"
00029 
00030 #define RGB( r,g,b )    SDL_MapRGB( SdlManager::the->getDisplay()->surf()->format, r, g, b )
00031 
00032 using namespace std;
00033 
00034 class SdlSurfaceContainer;
00035 class SdlAudio;
00036 class SdlMusicList;
00037 
00069 class DECLSPEC SdlManager
00070 {
00071 public:
00072     DECLSPEC SdlManager();
00073     virtual DECLSPEC ~SdlManager();
00074 
00080     DECLSPEC bool init();
00098     DECLSPEC bool init( TiXmlElement *el );
00109     DECLSPEC bool init( Uint32 width, Uint32 height, Uint32 &depth, bool fullscreen = true );
00114     DECLSPEC void destroy();
00115 
00117     bool isAudioInited()    { return bAudioInited; }
00119     bool isVideoInited()    { return bVideoInited; }
00120 
00125     DECLSPEC void refreshSoundVolumes();
00126 
00133     DECLSPEC SdlAudio *getAudioByName( const char *name );
00140     DECLSPEC SdlSurface *getSurfaceByName( const char *name );
00147     DECLSPEC SdlSurfaceContainer *getSurfacesByName( const char *name );
00154     DECLSPEC SdlMusicList *getMusicsByName( const char *name );
00159     SdlSurface *getDisplay()    { SDL_SetClipRect( surfDisplay->surf(), 0 ); return surfDisplay; }
00167     DECLSPEC bool getScreenSize( int &w, int &h );
00172     DECLSPEC SDL_Rect getScreenRect();
00173 
00187     DECLSPEC bool screenShot( const char *fn = 0, bool nooverwrite = true );
00189     static void grabInput(void) {if(bGrabInputEnabled) SDL_WM_GrabInput( SDL_GRAB_ON );}
00191     static void ungrabInput(void)   {SDL_WM_GrabInput( SDL_GRAB_OFF );}
00192 
00196     static SdlManager *the;
00204     DECLSPEC static SdlManager *getThe();
00205 
00207     static bool bGrabInputEnabled;
00208 private:
00209     bool initDisplay( Uint32 w, Uint32 h, Uint32 &d, bool fullscr = true );
00210     bool initAudio( Uint8 channels = 2/*stereo*/, int freq = 22050, Uint16 format = AUDIO_S16SYS );
00211     SdlSurface *surfDisplay;
00212 
00213     bool bVideoInited, bAudioInited;
00214     Uint32 nColorDepth;
00215     bool bFullScreen;
00216 
00217     list<SdlAudio*> lAudios, lFailedAudios;
00218     list<SdlSurface*> lSurfaces, lFailedSurfaces;
00219     list<SdlSurfaceContainer*> lSurfaceContainers, lFailedSurfaceContainers;
00220     list<SdlMusicList*> lMusicLists;
00221     typedef list<SdlAudio*>::iterator AudioIter;
00222     typedef list<SdlSurface*>::iterator SurfaceIter;
00223     typedef list<SdlSurfaceContainer*>::iterator SurfacesIter;
00224     typedef list<SdlMusicList*>::iterator MusicsIter;
00225 
00226     friend class SdlAudio;
00227     friend class SdlSurface;
00228     friend class SdlSurfaceContainer;
00229     friend class SdlMusicList;
00230 };
00231 
00232 #endif

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1