Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

basegfx.h

Go to the documentation of this file.
00001 
00015 /*
00016     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00017     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00018 
00019     This program is free software; you can redistribute it and/or modify
00020     it under the terms of the GNU General Public License as published by
00021     the Free Software Foundation; either version 2 of the License, or
00022     (at your option) any later version.
00023 
00024     This program is distributed in the hope that it will be useful,
00025     but WITHOUT ANY WARRANTY; without even the implied warranty of
00026     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027     GNU General Public License for more details.
00028 
00029     You should have received a copy of the GNU General Public License
00030     along with this program; see the file COPYING. If not, write to the 
00031     Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00032     Boston, MA  02111-1307  USA
00033 */
00034 
00035 #ifndef basegfxH
00036 #define basegfxH
00037 
00038 #include "libs/sdlmm/src/sdlmm.h"
00039 #include "global.h"
00040 #include "palette.h"
00041 #include "sdl/graphics.h"
00042 #include "graphics/surface.h"
00043 
00044 #pragma pack(1)
00045 
00046 const int colorDepth = 4;
00047 
00048 
00049 
00051 struct  tgraphmodeparameters {
00052             int           resolutionx      ;       
00053             int           resolutiony      ;       
00054             int           actsetpage       ;       
00055             int           windowstatus     ;       
00056             int           granularity      ;       
00057             int           scanlinelength   ;       
00058             int           scanlinenumber   ;       
00059             int           bytesperscanline ;       
00060             int           activegraphmode  ;       
00061             int           videomemory      ;       
00062             int           byteperpix       ;       
00063             PointerSizedInt linearaddress    ;       
00064             int           pagetoset        ;       
00065             char          redmasksize       ;      
00066             char          redfieldposition  ;      
00067             char          greenmasksize     ;      
00068             char          greenfieldposition;      
00069             char          bluemasksize      ;      
00070             char          bluefieldposition ;      
00071             char          bitperpix         ;      
00072             char          memorymodel;             
00073             int           directscreenaccess;      
00074             Surface*      surface;
00075             tgraphmodeparameters() : surface(NULL) {};
00076     };
00077 
00078 
00079 struct trleheader {
00080    Uint16 id;
00081    Uint16 size;
00082    char rle;
00083    Uint16 x;
00084    Uint16 y;
00085 };
00086 
00087 const int black = 0;
00088 const int    blue        = 1;
00089 const int    green       = 2;
00090 const int    cyan        = 3;
00091 const int    red         = 4;
00092 const int    magenta     = 5 ;
00093 const int    brown       = 6  ;
00094 const int    lightgray   = 7   ;
00095 const int    darkgray    = 8    ;
00096 const int    lightblue   = 9     ;
00097 const int    lightgreen  = 42  ; // 10      
00098 const int    lightcyan   = 119 ; // 11      
00099 const int    lightred    = 52  ; // 12        
00100 const int    lightmagenta = 5  ; // 13         
00101 const int    yellow       = 103;  // 14          
00102 const int    white        = 160;  // 15           
00103 
00104 extern tgraphmodeparameters   *agmp;
00105 extern tgraphmodeparameters   *hgmp;
00106 
00107 extern dacpalette256* activepalette256;
00108 
00109 
00110 extern tgraphmodeparameters activegraphmodeparameters;
00111 extern tgraphmodeparameters hardwaregraphmodeparameters;
00112 
00113 extern dacpalette256 activepalette;
00114 // extern int       palette16[256][4];
00115 extern void*     xlatbuffer;
00116 
00117 
00118 
00120  extern void bar(int x1, int y1, int x2, int y2, char color);
00121 
00123  extern void getimage(int x1, int y1, int x2, int y2, void *buffer);
00124 
00126  extern void putimage(int x1, int y1, void *buffer);
00127 
00145  extern void putxlatfilter ( int x1, int y1, void* pictbuffer, char* xlattables );
00146 
00148  extern void putspriteimage(int x1, int y1, void *buffer);
00149 
00153  extern void putrotspriteimage(int x1, int y1, void *buffer, int rotationvalue);
00154 
00156  extern void putrotspriteimage90(int x1, int y1, void *buffer, int rotationvalue);
00157 
00159  extern void putrotspriteimage180(int x1, int y1, void *buffer, int rotationvalue);
00160 
00162  extern void putrotspriteimage270(int x1, int y1, void *buffer, int rotationvalue);
00163 
00165  extern void puttexture ( int x1, int y1, int x2, int y2, void *texture );
00166 
00170  extern void putspritetexture ( int x1, int y1, int x2, int y2, void *texture );
00171 
00177  extern void putimageprt ( int x1, int y1, int x2, int y2, void *texture, int dx, int dy );
00178 
00179 #if 0
00180 
00183  extern void* xlatpict ( ppixelxlattable xl, void* pntr );
00184 #endif
00185 
00187  extern int loga2 ( int a );
00188  
00189 
00191  extern SPoint getPixelRotationLocation( SPoint pos, int width, int height, int degrees );
00192 
00193 
00195  extern void putpixel(int x1, int y1, int color);
00196  
00198  extern int getpixel(int x1, int y1);
00199 
00201  extern int imagesize(int x1, int y1, int x2, int y2);
00202  
00204  extern void getpicsize(void* p, int& width, int& height);
00205 
00207  extern int  getpicsize2(void* p );
00208 
00211  extern void* uncompress_rlepict ( void* pict );
00212 
00218  extern void  generategrayxlattable( ppixelxlattable tab, char offset, char size, dacpalette256* pal );
00219 
00220 #if 0
00221 
00224  extern void putshadow ( int x1, int y1, void* ptr, ppixelxlattable xl  );
00225 #endif
00226 
00227 
00230 extern void         rahmen( bool invers, int x1, int y1, int x2, int y2);
00231 
00233 extern void         line(int x1, int y1, int x2, int y2, char color );
00234 
00238 extern void xorline( int x1, int y1, int x2, int y2, char color );
00239 
00241 extern void rectangle(int x1, int y1, int x2, int y2, char color );
00242 
00246 extern void  xorrectangle(int x1, int y1, int x2, int y2, char color) ;
00247 
00249 void putinterlacedrotimage ( int x1, int y1, void* ptr, int rotation );
00250 
00253 void rotatepict90 ( void* s, void* d );
00254 
00257 void flippict ( void* s, void* d, int dir = 1 );
00258 
00263 void* halfpict ( void* vbuf );
00264 
00265 
00268 char* rotatepict ( void* image, int angle );
00269 
00270 
00273 char* rotatepict_grw ( void* image, int organgle );
00274 
00275 
00277 extern int getpixelfromimage ( void* buf, int x, int y );
00278 
00282 extern void ellipse ( int x1, int y1, int x2, int y2, int color, float tolerance );
00283 
00285 extern void putmask ( int x1, int y1, void* vbuf, int newtransparence );
00286 
00290 extern void putpicturemix ( int x1, int y1, void* ptr, int rotation, char* mixbuf );
00291 
00292 
00296 extern void copySurface2screen( void );
00297 extern void copySurface2screen( int x1, int y1, int x2, int y2 );
00298 
00299 
00300 
00303 class tdrawline {
00304          public: 
00305            void start ( int x1, int y1, int x2, int y2 );
00306            virtual void putpix ( int x, int y ) = 0;
00307            virtual ~tdrawline() {};
00308        };
00309 
00312 class tvirtualdisplay {
00313            Surface* surface;
00314            void* buf;
00315            tgraphmodeparameters oldparams;
00316            void init ( int x, int y, int col, int depth );
00317         public: 
00318            tvirtualdisplay ( int x, int y );
00319            tvirtualdisplay ( int x, int y, int color, int depth= 8 );
00320            Surface& getSurface();
00321            ~tvirtualdisplay ();
00322         };
00323 
00324 
00325 
00326 /**************************************************************
00327 The following routines were an early attempt at rewriting the graphic engine. 
00328 It was never continued and the routines are hardly used at all.
00329 They can be completely scrapped should the graphic engine be rewritten 
00330 sometime...
00331 ***************************************************************/
00332 
00334 struct trgbpixel {
00335        public:
00336          union {
00337             int rgb;
00338             #if SDL_BYTEORDER == SDL_LIL_ENDIAN
00339             struct { char r,g,b,a;  }channel;
00340             #else
00341             struct { char a,b,g,r;  }channel;
00342             #endif
00343           };
00344        //    mix ( const trgbpixel* pix );
00345           bool isTransparent();
00346         };
00347 
00348 #define alphabase 64
00349 
00350 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
00351 #define TCalpha 0xfefefe
00352 #else
00353 #define TCalpha 0xfefefe
00354 #endif
00355 
00357 class TrueColorImage {
00358          int xsize;
00359          int ysize;
00360          trgbpixel* pix;
00361       public:
00362          TrueColorImage ( int x, int y );
00363          trgbpixel getpix ( int x, int y );
00364          trgbpixel* getpix ( void );
00365          void setpix ( int x, int y, int r, int g, int b, int alpha = 0 );
00366          void setpix ( int x, int y, const trgbpixel& pix );
00367          int getxsize( void );
00368          int getysize( void );
00369 
00370          ~TrueColorImage();
00371 
00372    };
00373 
00375 extern TrueColorImage* zoomimage ( void* buf, int xsize, int ysize, dacpalette256 pal, int interpolate = 1, int proportional = 1 );
00376 
00379 extern char* convertimage ( TrueColorImage* img, dacpalette256 pal );
00380 
00382 extern TrueColorImage* convertimage2tc ( void* buf, dacpalette256 pal );
00383 
00386 // extern char truecolor2pal_table[262144];
00387 
00389 extern void putimage ( int x1, int y1, TrueColorImage* tci );
00390 extern void putimage_noalpha ( int x1, int y1, TrueColorImage* tci );
00391 
00392 TrueColorImage* smoothimage ( TrueColorImage* src );
00393 
00394 
00395 extern TrueColorImage* getimage(int x1, int y1, int x2, int y2 );
00396 
00397 
00399 class fatalgraphicserror { 
00400         char st[1000];
00401       public:
00402         fatalgraphicserror ( const char* strng );
00403         fatalgraphicserror ( void );
00404       };
00405 
00412 class collategraphicoperations {
00413          int olddirectscreenaccess;
00414          int x1, y1, x2, y2;
00415          int status;
00416        public:
00417          collategraphicoperations ( void );
00418          collategraphicoperations ( int _x1, int _y1, int _x2, int _y2 );
00419          ~collategraphicoperations ();
00420          void on ( void );
00421          void off ( void );
00422 };
00423 
00424 
00425 
00426 #pragma pack()
00427 
00429 extern int fullscreen;
00430 
00432 extern void setWindowCaption ( const char* s );
00433 
00434 #ifdef use_truecolor2pal
00435 
00439 extern void* convertSurface ( SDLmm::Surface& s, bool paletteTranslation = true );
00440 #endif
00441 
00442 extern SPoint getPixelRotationLocation( SPoint pos, int width, int height, int degrees );
00443 
00444 #endif

Generated on Tue Jun 24 01:27:35 2008 for Advanced Strategic Command by  doxygen 1.4.2