1 /******************************************************************************
2 * Arachnoid Graphics Plugin for Mupen64Plus
3 * http://bitbucket.org/wahrhaft/mupen64plus-video-arachnoid/
5 * Copyright (C) 2007 Kristofer Karlsson, Rickard Niklasson
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *****************************************************************************/
22 #include "CombinerBase.h"
23 #include "CombinerStructs.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
28 CombinerBase::CombinerBase()
30 m_fillColor[0] = m_blendColor[0] = m_primColor[0] = m_envColor[0] = 0;
31 m_fillColor[1] = m_blendColor[1] = m_primColor[1] = m_envColor[1] = 0;
32 m_fillColor[2] = m_blendColor[2] = m_primColor[2] = m_envColor[2] = 0;
33 m_fillColor[3] = m_blendColor[3] = m_primColor[3] = m_envColor[3] = 1;
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
39 CombinerBase::~CombinerBase()
44 //-----------------------------------------------------------------------------
46 //! @param r Red component of color (0.0 - 1.0)
47 //! @param g Green component of color (0.0 - 1.0)
48 //! @param b Blue component of color (0.0 - 1.0)
49 //! @param a Alpha component of color (0.0 - 1.0)
50 //-----------------------------------------------------------------------------
51 void CombinerBase::setFillColor (float r, float g, float b, float a)
59 //-----------------------------------------------------------------------------
61 //! @param r Red component of color (0.0 - 1.0)
62 //! @param g Green component of color (0.0 - 1.0)
63 //! @param b Blue component of color (0.0 - 1.0)
64 //! @param a Alpha component of color (0.0 - 1.0)
65 //-----------------------------------------------------------------------------
66 void CombinerBase::setBlendColor(float r, float g, float b, float a)
74 //-----------------------------------------------------------------------------
76 //! @param r Red component of color (0.0 - 1.0)
77 //! @param g Green component of color (0.0 - 1.0)
78 //! @param b Blue component of color (0.0 - 1.0)
79 //! @param a Alpha component of color (0.0 - 1.0)
80 //-----------------------------------------------------------------------------
81 void CombinerBase::setPrimColor (float r, float g, float b, float a)
89 //-----------------------------------------------------------------------------
90 //! Set Enviroment Color
91 //! @param r Red component of color (0.0 - 1.0)
92 //! @param g Green component of color (0.0 - 1.0)
93 //! @param b Blue component of color (0.0 - 1.0)
94 //! @param a Alpha component of color (0.0 - 1.0)
95 //-----------------------------------------------------------------------------
96 void CombinerBase::setEnvColor(float r, float g, float b, float a)
104 //-----------------------------------------------------------------------------
105 //! Get Combiner Color
106 //! @param[in] colorSource From which colorsource to retrive color values
107 //! \arg \c PRIMITIVE Get color from primative color
108 //! \arg \c ENVIRONMENT Get color from environment color
109 //! \arg \c PRIMITIVE_ALPHA Get color from primatives alpha value
110 //! \arg \c ENV_ALPHA Get color from environment colors alpha value
111 //! \arg \c PRIM_LOD_FRAC Get color from primative-LOD-frac value
112 //! \arg \c ONE Get white color
113 //! \arg \c ZERO Get black color
114 //! @param[in] alphaSource From which alphasource to retrive alpha value
115 //! \arg \c PRIMITIVE_ALPHA Get alpha value from primitive colors alpha value
116 //! \arg \c ENV_ALPHA Get alpha value from environment colors alpha value
117 //! \arg \c PRIM_LOD_FRAC Get alpha value from primative-LOD-frac value
118 //! \arg \c ONE Set alpha value to 1.0
119 //! \arg \c ZERO Set alpha value to 0.0
120 //! @param[out] out The combiner color with color and alpha value
121 //-----------------------------------------------------------------------------
122 void CombinerBase::getCombinerColor(float out[4], short colorSrc, short alphaSrc)
128 out[0] = m_primColor[0];
129 out[1] = m_primColor[1];
130 out[2] = m_primColor[2];
133 out[0] = m_envColor[0];
134 out[1] = m_envColor[1];
135 out[2] = m_envColor[2];
137 case PRIMITIVE_ALPHA:
138 out[0] = m_primColor[3];
139 out[1] = m_primColor[3];
140 out[2] = m_primColor[3];
143 out[0] = m_envColor[3];
144 out[1] = m_envColor[3];
145 out[2] = m_envColor[3];
148 out[0] = m_primLodFrac;
149 out[1] = m_primLodFrac;
150 out[2] = m_primLodFrac;
167 case PRIMITIVE_ALPHA:
168 out[3] = m_primColor[3];
171 out[3] = m_envColor[3];
174 out[3] = m_primLodFrac;