sdlsurface.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 SDLSURFACE_H
00023 #define SDLSURFACE_H
00024 
00025 #include "SDL/SDL.h"
00026 #include <list>
00027 
00028 using namespace std;
00029 
00044 class DECLSPEC SdlSurface
00045 {
00046 public:
00053     DECLSPEC SdlSurface( const char *name );
00062     DECLSPEC SdlSurface( SDL_Surface *surf, const char *name );
00074     DECLSPEC SdlSurface( Uint32 w, Uint32 h, const char *name = (char*)-1, Uint32 flags = SDL_HWSURFACE );
00075     virtual DECLSPEC ~SdlSurface();
00076 
00082     void DECLSPEC rename( const char *newname );
00084     const char *getName() const         { return chName; }
00085 
00098     DECLSPEC bool fastBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, SDL_Rect *src );
00107     DECLSPEC bool fill( SDL_Rect *r, Uint32 color );
00118     DECLSPEC bool zoomBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double xZoom, double yZoom, bool smooth = false );
00126     DECLSPEC bool stretchBlit( SdlSurface *src_surf, SDL_Rect *dst, bool smooth = false );
00137     DECLSPEC bool rotozoomBlit( SdlSurface *src_surf, Sint16 xDst, Sint16 yDst, double angle, double zoom, bool smooth = false );
00138     
00140     SDL_Surface *surf()         { return surface; }
00145     void getSize( int &w, int &h )  { w = surface->w;   h = surface->h; }
00150     void getSize( Uint16 &w, Uint16 &h )    { w = surface->w;   h = surface->h; }
00151 
00153     Uint32 getWidth() const     { return surface->w; }
00155     Uint32 getHeight() const    { return surface->h; }
00156 
00162     void setClip( const SDL_Rect &r )   { SDL_SetClipRect( surface, &r ); }
00166     void setNoClip()    { SDL_SetClipRect( surface, NULL ); }
00170     const SDL_Rect &getClip() const     { return surface->clip_rect; }
00175     DECLSPEC void setColorKey( Uint32 color );
00181     DECLSPEC void setAlphaValue( int a );
00182 
00188     bool lock() { return SDL_LockSurface( surface ) >= 0; }
00192     void unlock()   { SDL_UnlockSurface( surface ); }
00193 
00197     virtual DECLSPEC bool saveToFile( const char *fn );
00198 
00199 protected:
00204     virtual DECLSPEC void onRefresh()   {}
00206     DECLSPEC void failed();
00207 
00209     SDL_Surface *surface;
00210 
00211 private:
00212     void initName( const char *name );
00213     char *chName;
00214     bool bFailed;
00215 };
00216 
00217 #endif

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