drawlibs.h

Go to the documentation of this file.
00001 
00002 /*
00003  * drawlibs.h - code for manipulating SDL surfaces and drawing
00004  * Initial design by Eduardo B. Fonseca <ebf@aedsolucoes.com.br>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 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  * Library General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public
00017  * License along with this library; if not, write to the Free
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef DRAWLIBS_H
00023 #define DRAWLIBS_H
00024 
00025 #include "SDL.h"
00026 
00027 template<typename T> 
00028 inline int sgn(T x)
00029 {
00030     return x < 0 ? -1 : (x > 0 ? 1 : 0);
00031 }
00032 
00033 DLLEXPORT SDL_Surface *CreateSurface(Uint32 flags, int width, int height,
00034                                      int bpp = 32);
00035 DLLEXPORT void ConvertSurface(SDL_Surface ** surface);
00036 
00037 DLLEXPORT void DrawPixel(SDL_Surface * screen, int x, int y, Uint32 color);
00038 DLLEXPORT void DrawLine(SDL_Surface * screen, int x1, int y1, int x2, int y2,
00039                         Uint32 color);
00040 DLLEXPORT void DrawRect(SDL_Surface * screen, int x1, int y1, int x2, int y2,
00041                         Uint32 color);
00042 DLLEXPORT void DrawRound(SDL_Surface * screen, int x0, int y0, int w, int h,
00043                          int corner, Uint32 color);
00044 
00045 DLLEXPORT void vertgradient(SDL_Surface * surf, SDL_Color c1, SDL_Color c2,
00046                             Uint8 alpha = 255);
00047 DLLEXPORT void vertgradient2(SDL_Surface * surf, SDL_Rect & gradRect,
00048                              SDL_Color c1, SDL_Color c2, Uint8 alpha = 255);
00049 DLLEXPORT void horizgradient2(SDL_Surface * surf, SDL_Rect & gradRect,
00050                               SDL_Color c1, SDL_Color c2, Uint8 alpha = 255);
00051 
00052 DLLEXPORT Uint32 GetPixel(SDL_Surface * surface, int x, int y);
00053 DLLEXPORT void FloodFill(SDL_Surface * screen, int x, int y, Uint32 c);
00054 DLLEXPORT void DrawTriangle(SDL_Surface * s, int x[3], int y[3], Uint32 c);
00055 
00056 enum
00057 {
00058     ARROW_UP,
00059     ARROW_DOWN,
00060     ARROW_LEFT,
00061     ARROW_RIGHT
00062 };
00063 DLLEXPORT void DrawArrow(SDL_Surface * s, int type, int x, int y, int a,
00064                          Uint32 color, bool fill = false, Uint32 fillcolor = 0);
00065 
00066 #define SLOCK(surface) \
00067     do { \
00068         if(SDL_MUSTLOCK(surface)) \
00069          SDL_LockSurface(surface); \
00070     } while(0)
00071 
00072 #define SUNLOCK(surface) \
00073     do { \
00074         if(SDL_MUSTLOCK(surface)) \
00075          SDL_UnlockSurface(surface); \
00076     } while(0)
00077 
00078 #endif

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7