Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SDLGraphicContext.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2001-2005 Stephane Magnenat & Luc-Olivier de Charrière
00003   for any question or comment contact us at nct@ysagoon.com or nuage@ysagoon.com
00004 
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU General Public License as published by
00007   the Free Software Foundation; either version 2 of the License, or
00008   (at your option) any later version.
00009 
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013   GNU General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this program; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00018 */
00019 
00020 #ifndef __SDLGRAPHICCONTEXT_H
00021 #define __SDLGRAPHICCONTEXT_H
00022 
00023 #include "GAGSys.h"
00024 #include "GraphicContext.h"
00025 
00030 namespace GAG
00031 {
00034     class SDLDrawableSurface: public virtual DrawableSurface
00035     {
00036     protected:
00037         friend class SDLSprite;
00038         SDL_Surface *surface; 
00039         SDL_Rect clipRect; 
00040         Uint32 flags; 
00041         
00042     protected:
00043         friend class SDLGraphicContext;
00045         SDLDrawableSurface();
00046         
00047     public:
00048         virtual ~SDLDrawableSurface() { if (surface) SDL_FreeSurface(surface); }
00049         virtual bool setRes(int w, int h, int depth=32, Uint32 flags=DEFAULT);
00050         virtual void setAlpha(bool usePerPixelAlpha=false, Uint8 alphaValue=ALPHA_OPAQUE);
00051         virtual int getW(void) { if(surface) return surface->w; else return 0;}
00052         virtual int getH(void) { if(surface) return surface->h; else return 0; }
00053         virtual int getDepth(void) { if(surface) return surface->format->BitsPerPixel; else return 0; }
00054         virtual int getFlags(void) { return flags; }
00055         virtual void setClipRect(int x, int y, int w, int h);
00056         virtual void setClipRect(void);
00057         virtual void loadImage(const char *name);
00058         virtual void drawSprite(int x, int y, Sprite *sprite, int index=0);
00059         virtual void drawPixel(int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00060         virtual void drawRect(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00061         virtual void drawFilledRect(int x, int y, int w, int h, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00062         virtual void drawVertLine(int x, int y, int l, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00063         virtual void drawHorzLine(int x, int y, int l, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00064         virtual void drawLine(int x1, int y1, int x2, int y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00065         virtual void drawCircle(int x, int y, int ray, Uint8 r, Uint8 g, Uint8 b, Uint8 a=ALPHA_OPAQUE);
00066         virtual void drawString(int x, int y, const Font *font, int i);
00067         virtual void drawString(int x, int y, const Font *font, const char *msg);
00068         virtual void drawString(int x, int y, int w, const Font *font, const char *msg);
00069         virtual void drawSurface(int x, int y, DrawableSurface *surface);
00070         virtual void updateRects(SDL_Rect *rects, int size) { }
00071         virtual void updateRect(int x, int y, int w, int h) { }
00072         virtual void *getPixelPointer(void) { return surface->pixels; }
00073     };
00074     
00077     class SDLGraphicContext:  public SDLDrawableSurface, public virtual GraphicContext
00078     {
00079     protected:
00080         friend class GraphicContext;
00082         SDLGraphicContext(void);
00083         
00084     public:
00085         virtual ~SDLGraphicContext(void);
00086     
00087         virtual bool setRes(int w, int h, int depth=32, Uint32 flags=DEFAULT);
00088         virtual void setCaption(const char *title, const char *icon) { SDL_WM_SetCaption(title, icon); }
00089     
00090         virtual void loadImage(const char *name);
00091     
00092         virtual Font *loadFont(const char *filename, unsigned size);
00093         virtual DrawableSurface *createDrawableSurface(const char *name=NULL);
00094     
00095         virtual void nextFrame(void);
00096         virtual void updateRects(SDL_Rect *rects, int size);
00097         virtual void updateRect(int x, int y, int w, int h);
00098         
00099         virtual void printScreen(const char *filename);
00100     };
00101 }
00102 
00103 #endif

Generated on Mon Oct 24 17:38:25 2005 for Teem by  doxygen 1.4.2