XFormBlend.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2003  The 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 #include "pent_include.h"
00020 #include "XFormBlend.h"
00021 #include "Texture.h"
00022 
00023 const uint8 U8XFormPal[1024] = {
00024         0,      0,      0,      0,
00025         0,      0,      0,      0,
00026         0,      0,      0,      0,
00027         0,      0,      0,      0,
00028         0,      0,      0,      0,
00029         0,      0,      0,      0,
00030         0,      0,      0,      0,
00031         0,      0,      0,      0,
00032         48,     48,     48,     80,     // (green->dark grey)
00033         24,     24,     24,     80,     // (black->vdark grey)
00034         64,     64,     24,     64,     // (yellow)
00035         80,     80,     80,     80,     // (white->grey)
00036         180,90, 0,      80,     // (red->orange)
00037         0,      0,      252,40, // (blue)
00038         0,      0,      104,40, // (blue)
00039         0,      0,      0,      0
00040 };
00041 
00042 #if 0
00043 //
00044 // XFORM Blend Funcs
00045 //
00046 
00047 // BlendFunc is always glBlendFunc (GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
00048 
00049 #define XFORM_BLEND_FUNC(ra,ga,ba,a) { \
00050         r*=255-a; \
00051         g*=255-a; \
00052         b*=255-a; \
00053         r+=ra*255; \
00054         g+=ga*255; \
00055         b+=ba*255; }
00056 
00057 //
00058 // Colour 8 (green->dark grey)
00059 //
00060 // xform_palette[32] = 48;
00061 // xform_palette[33] = 48;
00062 // xform_palette[34] = 48;
00063 // xform_palette[35] = 80;
00064 //
00065 // dest*175 + {48,48,48}
00066 //
00067 uint32 P_FASTCALL U8xformCol8 (uint32 col)
00068 {
00069         static uint32 r, g, b;
00070         UNPACK_RGB8(col,r,g,b);
00071         XFORM_BLEND_FUNC(48,48,48,80);
00072         return PACK_RGB16(r,g,b);
00073 }
00074 
00075 // Adjust 9 (black->vdark grey)
00076 // xform_palette[36] = 24;
00077 // xform_palette[37] = 24;
00078 // xform_palette[38] = 24;
00079 // xform_palette[39] = 80;
00080 uint32 P_FASTCALL U8xformCol9 (uint32 col)
00081 {
00082         static uint32 r, g, b;
00083         UNPACK_RGB8(col,r,g,b);
00084         XFORM_BLEND_FUNC(24,24,24,80);
00085         return PACK_RGB16(r,g,b);
00086 }
00087 
00088 // Adjust 9 (yellow)
00089 // xform_palette[40] = 64;
00090 // xform_palette[41] = 64;
00091 // xform_palette[42] = 24;
00092 // xform_palette[43] = 64;
00093 uint32 P_FASTCALL U8xformCol10 (uint32 col)
00094 {
00095         static uint32 r, g, b;
00096         UNPACK_RGB8(col,r,g,b);
00097         XFORM_BLEND_FUNC(64,64,24,64);
00098         return PACK_RGB16(r,g,b);
00099 }
00100 
00101 // Adjust 11 (white->grey)
00102 // xform_palette[44] = 80;
00103 // xform_palette[45] = 80;
00104 // xform_palette[46] = 80;
00105 // xform_palette[47] = 80;
00106 uint32 P_FASTCALL U8xformCol11 (uint32 col)
00107 {
00108         static uint32 r, g, b;
00109         UNPACK_RGB8(col,r,g,b);
00110         XFORM_BLEND_FUNC(80,80,80,80);
00111         return PACK_RGB16(r,g,b);
00112 }
00113 
00114 // Adjust 12 (red->orange)
00115 // xform_palette[48] = 180;
00116 // xform_palette[49] = 90;
00117 // xform_palette[50] = 0;
00118 // xform_palette[51] = 80;
00119 uint32 P_FASTCALL U8xformCol12 (uint32 col)
00120 {
00121         static uint32 r, g, b;
00122         UNPACK_RGB8(col,r,g,b);
00123         XFORM_BLEND_FUNC(180,90,0,80);
00124         if (r>65535) r = 65535;
00125         if (g>65535) g = 65535;
00126         return PACK_RGB16(r,g,b);
00127 }
00128 
00129 // 13 (blue) just need alpha modified
00130 // xform_palette[52] = 0;
00131 // xform_palette[53] = 0;
00132 // xform_palette[54] = 252;
00133 // xform_palette[55] = 40;
00134 uint32 P_FASTCALL U8xformCol13 (uint32 col)
00135 {
00136         static uint32 r, g, b;
00137         UNPACK_RGB8(col,r,g,b);
00138         XFORM_BLEND_FUNC(0,0,252,40);
00139         if (b>65535) b = 65535;
00140         return PACK_RGB16(r,g,b);
00141 }
00142 
00143 // 14 (blue) just need alpha modified
00144 // xform_palette[56] = 0;
00145 // xform_palette[57] = 0;
00146 // xform_palette[58] = 104;
00147 // xform_palette[59] = 40;
00148 uint32 P_FASTCALL U8xformCol14 (uint32 col)
00149 {
00150         static uint32 r, g, b;
00151         UNPACK_RGB8(col,r,g,b);
00152         XFORM_BLEND_FUNC(0,0,104,40);
00153         if (b>65535) b = 65535;
00154         return PACK_RGB16(r,g,b);
00155 }
00156 
00157 const xformBlendFuncType        U8XFormFuncs[256] = {
00158         0,                                                                      // 0    
00159         0,                                                                      // 1
00160         0,                                                                      // 2    
00161         0,                                                                      // 3    
00162         0,                                                                      // 4    
00163         0,                                                                      // 5    
00164         0,                                                                      // 6    
00165         0,                                                                      // 7    
00166         static_cast<xformBlendFuncType>(&U8xformCol8),  // 8 (green->dark grey) 
00167         static_cast<xformBlendFuncType>(&U8xformCol9),  // 9 (black->vdark grey)
00168         static_cast<xformBlendFuncType>(&U8xformCol10), // 10 (yellow)
00169         static_cast<xformBlendFuncType>(&U8xformCol11), // 11 (white->grey)
00170         static_cast<xformBlendFuncType>(&U8xformCol12), // 12 (red->orange)
00171         static_cast<xformBlendFuncType>(&U8xformCol13), // 13 (blue)
00172         static_cast<xformBlendFuncType>(&U8xformCol14), // 14 (blue)
00173         0                                                                       // 15
00174 };
00175 
00176 #endif
00177 

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