OpenMortal Apocalypse mirror
Sourceforge mirror
SourceForge.net Logo
      News | Info | Characters | Arenas | Screenshots | Forums | Download  
Developer: Making of | Toplevel design | Character-HOWTO | AI Design | Submit a Character
Documentation: Main Page | Modules | Class Hierarchy | Class List | File List

sge_internal.h

Go to the documentation of this file.
00001 /*
00002 *   SDL Graphics Extension
00003 *   SGE internal header
00004 *
00005 *   Started 000627
00006 *
00007 *   License: LGPL v2+ (see the file LICENSE)
00008 *   (c)2000-2001 Anders Lindström
00009 */
00010 
00011 /*********************************************************************
00012  *  This library is free software; you can redistribute it and/or    *
00013  *  modify it under the terms of the GNU Library General Public      *
00014  *  License as published by the Free Software Foundation; either     *
00015  *  version 2 of the License, or (at your option) any later version. *
00016  *********************************************************************/
00017 
00018 #ifndef sge_internal_H
00019 #define sge_internal_H
00020 
00021 /* This header is included in all sge_*.h files */
00022 
00023 #include "sge_config.h"
00024 
00025 /*
00026 *  C compatibility
00027 */
00028 #ifndef __cplusplus
00029     #define sge_C_ONLY
00030     #define _SGE_NO_CLASSES
00031 #endif
00032 #ifdef _SGE_C
00033     #define sge_C_ONLY
00034     #define _SGE_NO_CLASSES
00035 #endif
00036 
00037 
00038 /*
00039 *  This is traditional
00040 */
00041 #ifndef PI
00042     #define PI 3.1414926535
00043 #endif
00044 
00045 
00046 /*
00047 *  Bit flags
00048 */
00049 #define SGE_FLAG0 0x00
00050 #define SGE_FLAG1 0x01
00051 #define SGE_FLAG2 0x02
00052 #define SGE_FLAG3 0x04
00053 #define SGE_FLAG4 0x08
00054 #define SGE_FLAG5 0x10
00055 #define SGE_FLAG6 0x20
00056 #define SGE_FLAG7 0x40
00057 #define SGE_FLAG8 0x80
00058 
00059 
00060 /*
00061 *  Define the right alpha values 
00062 *  (they were fliped in SDL 1.1.5+)
00063 */
00064 #ifndef SDL_ALPHA_OPAQUE
00065     #define SDL_ALPHA_OPAQUE 0
00066 #endif
00067 #ifndef SDL_ALPHA_TRANSPARENT
00068     #define SDL_ALPHA_TRANSPARENT 255
00069 #endif
00070 
00071 
00072 /*
00073 *  Older versions of SDL doesn't have SDL_VERSIONNUM
00074 */
00075 #ifndef SDL_VERSIONNUM
00076     #define SDL_VERSIONNUM(X, Y, Z)      \
00077         (X)*1000 + (Y)*100 + (Z)
00078 #endif
00079 
00080 
00081 /*
00082 *  Older versions of SDL doesn't have SDL_CreateRGBSurface
00083 */
00084 #ifndef SDL_AllocSurface
00085     #define SDL_CreateRGBSurface  SDL_AllocSurface
00086 #endif
00087 
00088 
00089 /*
00090 *  Macro to get clipping
00091 */
00092 #if SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= \
00093     SDL_VERSIONNUM(1, 1, 5)
00094     #define sge_clip_xmin(pnt) pnt->clip_rect.x
00095     #define sge_clip_xmax(pnt) pnt->clip_rect.x + pnt->clip_rect.w-1
00096     #define sge_clip_ymin(pnt) pnt->clip_rect.y
00097     #define sge_clip_ymax(pnt) pnt->clip_rect.y + pnt->clip_rect.h-1
00098 #else
00099     #define sge_clip_xmin(pnt) pnt->clip_minx
00100     #define sge_clip_xmax(pnt) pnt->clip_maxx
00101     #define sge_clip_ymin(pnt) pnt->clip_miny
00102     #define sge_clip_ymax(pnt) pnt->clip_maxy
00103 #endif
00104 
00105 
00106 /*
00107 *  Macro to get the smallest bounding box from two (SDL_Rect) rectangles
00108 */
00109 #define sge_RectUnion(dst_rect, rect1, rect2)\
00110     dst_rect.x = (rect1.x < rect2.x)? rect1.x:rect2.x;\
00111     dst_rect.y = (rect1.y < rect2.y)? rect1.y:rect2.y;\
00112     dst_rect.w = (rect1.x + rect1.w > rect2.x + rect2.w)? rect1.x + rect1.w - dst_rect.x : rect2.x + rect2.w - dst_rect.x;\
00113     dst_rect.h = (rect1.y + rect1.h > rect2.y + rect2.h)? rect1.y + rect1.h - dst_rect.y : rect2.y + rect2.h - dst_rect.y;
00114 
00115 
00116 /*
00117 *  We need to use alpha sometimes but older versions of SDL doesn't have
00118 *  alpha support.
00119 */
00120 #if SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) >= \
00121     SDL_VERSIONNUM(1, 1, 5)
00122     #define sge_MapRGBA SDL_MapRGBA
00123     #define sge_GetRGBA SDL_GetRGBA
00124 #else
00125     #define sge_MapRGBA(fmt, r, g, b, a) SDL_MapRGB(fmt, r, g, b)
00126     #define sge_GetRGBA(pixel, fmt, r, g, b, a) SDL_GetRGBA(pixel, fmt, r, g, b)
00127 #endif
00128 
00129 
00130 /*
00131 *  Some compilers use a special export keyword
00132 *  Thanks to Seung Chan Lim (limsc@maya.com or slim@djslim.com) to pointing this out
00133 *  (From SDL)
00134 */
00135 #ifndef DECLSPEC
00136     #ifdef __BEOS__
00137         #if defined(__GNUC__)
00138             #define DECLSPEC __declspec(dllexport)
00139         #else
00140             #define DECLSPEC __declspec(export)
00141         #endif
00142     #else
00143     #ifdef WIN32
00144         #define DECLSPEC __declspec(dllexport)
00145     #else
00146         #define DECLSPEC
00147     #endif
00148     #endif
00149 #endif
00150 
00151 #endif /* sge_internal_H */