2 Copyright (C) 2003 Rice1964
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include "OGLDecodedMux.h"
21 //========================================================================
22 void COGLDecodedMux::Simplify(void)
24 DecodedMux::Simplify();
27 void COGLDecodedMux::Reformat(void)
29 DecodedMux::Reformat();
30 mType = max(max(max(splitType[0], splitType[1]),splitType[2]),splitType[3]);
33 void COGLExtDecodedMux::Simplify(void)
34 //========================================================================
36 COGLDecodedMux::Simplify();
37 FurtherFormatForOGL2();
38 Reformat(); // Reformat again
41 void COGLExtDecodedMux::FurtherFormatForOGL2(void)
43 // This function is used by OGL 1.2, no need to call this function
44 // for Nvidia register combiner
46 // And OGL 1.2 extension only supports 1 constant color, we can not use both PRIM and ENV
47 // constant color, and we can not use SPECULAR color as the 2nd color.
49 // To futher format the mux.
50 // - For each stage, allow only 1 texel, change the 2nd texel in the same stage to MUX_SHADE
51 // - Only allow 1 constant color. Count PRIM and ENV, left the most used one, and change
52 // the 2nd one to MUX_SHADE
54 if( Count(MUX_PRIM) >= Count(MUX_ENV) )
56 ReplaceVal(MUX_ENV, MUX_PRIM);
57 //ReplaceVal(MUX_ENV, MUX_SHADE);
58 //ReplaceVal(MUX_ENV, MUX_1);
59 //ReplaceVal(MUX_PRIM, MUX_0);
63 //ReplaceVal(MUX_PRIM, MUX_ENV);
64 //ReplaceVal(MUX_PRIM, MUX_SHADE);
65 ReplaceVal(MUX_PRIM, MUX_0);
69 // Because OGL 1.2, we may use more than 1 texture unit, but for each texture unit,
70 // we can not use multitexture to do color combiner. Each combiner stage can only
73 if( isUsed(MUX_TEXEL0) && isUsed(MUX_TEXEL1) )
75 if( Count(MUX_TEXEL0,0)+Count(MUX_TEXEL0,1) >= Count(MUX_TEXEL1,0)+Count(MUX_TEXEL1,1) )
77 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 0);
78 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 1);
82 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 0);
83 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 1);
86 if( Count(MUX_TEXEL0,2)+Count(MUX_TEXEL0,3) >= Count(MUX_TEXEL1,2)+Count(MUX_TEXEL1,3) )
88 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 2);
89 ReplaceVal(MUX_TEXEL1, MUX_TEXEL0, 3);
93 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 2);
94 ReplaceVal(MUX_TEXEL0, MUX_TEXEL1, 3);
101 void COGLExtDecodedMuxTNT2::FurtherFormatForOGL2(void)
103 if( Count(MUX_PRIM) >= Count(MUX_ENV) )
105 //ReplaceVal(MUX_ENV, MUX_PRIM);
106 //ReplaceVal(MUX_ENV, MUX_SHADE);
107 ReplaceVal(MUX_ENV, MUX_1);
108 //ReplaceVal(MUX_PRIM, MUX_0);
112 //ReplaceVal(MUX_PRIM, MUX_ENV);
113 //ReplaceVal(MUX_PRIM, MUX_SHADE);
114 ReplaceVal(MUX_PRIM, MUX_0);