XFormBlend.h

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2003  Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef XFORMBLEND_H
00020 #define XFORMBLEND_H
00021 
00022 #include "Texture.h"
00023 #include "RenderSurface.h"
00024 
00025 #ifndef P_FASTCALL
00026 #ifdef _MSC_VER
00027 #define P_FASTCALL __fastcall
00028 #elif (defined(WIN32) && defined(FASTCALL))
00029 #define P_FASTCALL FASTCALL
00030 #else
00031 #define P_FASTCALL
00032 #endif
00033 #endif
00034 
00035 extern const uint8 U8XFormPal[1024];
00036 
00037 inline uint32 P_FASTCALL BlendPreModulated(uint32 src, uint32 dst)
00038 {
00039         uint32 r, g, b;
00040         UNPACK_RGB8(dst,r,g,b);
00041         r*=256-TEX32_A(src);
00042         g*=256-TEX32_A(src);
00043         b*=256-TEX32_A(src);
00044         r+=256*TEX32_R(src);
00045         g+=256*TEX32_G(src);
00046         b+=256*TEX32_B(src);
00047         return PACK_RGB16(r>65535?65535:r, g>65535?65535:g, b>65535?65535:b);
00048 }
00049 
00050 inline uint32 P_FASTCALL BlendPreModFast(uint32 src, uint32 dst)
00051 {
00052         uint32 r, g, b;
00053         UNPACK_RGB8(dst,r,g,b);
00054         r*=256-TEX32_A(src);
00055         g*=256-TEX32_A(src);
00056         b*=256-TEX32_A(src);
00057         r+=256*TEX32_R(src);
00058         g+=256*TEX32_G(src);
00059         b+=256*TEX32_B(src);
00060         return PACK_RGB16(r, g, b);
00061 }
00062 
00063 // This does the red highlight blending. 
00064 inline uint32 P_FASTCALL BlendHighlight(uint32 src, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica)
00065 {
00066         uint32 sr, sg, sb;
00067         UNPACK_RGB8(src,sr,sg,sb);
00068         return PACK_RGB16(sr*ica+cr*ca, sg*ica+cg*ca, sb*ica+cb*ca);
00069 }
00070 
00071 // This does the invisible blending. I've set it to about 40%
00072 inline uint32 P_FASTCALL BlendInvisible(uint32 src, uint32 dst)
00073 {
00074         uint32 sr, sg, sb;
00075         uint32 dr, dg, db;
00076         UNPACK_RGB8(src,sr,sg,sb);
00077         UNPACK_RGB8(dst,dr,dg,db);
00078         return PACK_RGB16(sr*100+dr*156,
00079                                                 sg*100+dg*156,
00080                                                 sb*100+db*156);
00081 }
00082 
00083 // This does the translucent highlight blending. (50%) 
00084 inline uint32 P_FASTCALL BlendHighlightInvis(uint32 src, uint32 dst, uint32 cr, uint32 cg, uint32 cb, uint32 ca, uint32 ica)
00085 {
00086         uint32 sr, sg, sb;
00087         uint32 dr, dg, db;
00088         UNPACK_RGB8(src,sr,sg,sb);
00089         UNPACK_RGB8(dst,dr,dg,db);
00090         return PACK_RGB16(((sr*ica+cr*ca)>>1)+(dr<<7), 
00091                                                 ((sg*ica+cg*ca)>>1)+(dg<<7), 
00092                                                 ((sb*ica+cb*ca)>>1)+(db<<7));
00093 }
00094 
00095 
00096 #endif

Generated on Fri Jul 27 22:27:54 2007 for pentagram by  doxygen 1.4.7