00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 // 00010 // This library is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * ブレンドスプライトステートヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef BLEND_SPRITE_STATE_H_ 00026 #define BLEND_SPRITE_STATE_H_ 00027 00028 #include "Graphics2D/SpriteState/SpriteState.h" 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * ブレンドスプライトステート 00035 */ 00036 class BlendSpriteState : public SpriteState{ 00037 public: 00038 //-------------------------------------------------------------------------- 00039 // テンプレートステート 00040 //-------------------------------------------------------------------------- 00041 /// 半透明 00042 static const BlendSpriteState translucent; 00043 00044 /// 加算 00045 static const BlendSpriteState addState; 00046 00047 /// デフォルト 00048 static const BlendSpriteState defaultState; 00049 00050 //-------------------------------------------------------------------------- 00051 // ブレンドモード 00052 //-------------------------------------------------------------------------- 00053 /// ブレンドモード 00054 enum BlendMode{ 00055 blendModeDisable = 0, 00056 blendModeAdd, 00057 blendModeSubtract, 00058 blendModeInverseSubtract, 00059 blendModeMinimum, 00060 blendModeMaximum, 00061 blendModeMax, 00062 }; 00063 00064 /** 00065 * ブレンドモードから文字列への変換 00066 * @param blendMode ブレンドモード 00067 * @return ブレンドモード文字列 00068 */ 00069 static const String& blendModeToString(BlendMode blendMode); 00070 00071 /** 00072 * 文字列からブレンドモードへの変換 00073 * @param blendModeString ブレンドモード文字列 00074 * @return ブレンドモード 00075 */ 00076 static BlendMode blendModeFromString(const String& blendModeString); 00077 00078 //-------------------------------------------------------------------------- 00079 // ブレンドステート 00080 //-------------------------------------------------------------------------- 00081 /// ブレンドステート 00082 enum BlendState{ 00083 blendStateZero = 0, 00084 blendStateOne, 00085 blendStateSourceColor, 00086 blendStateInverseSourceColor, 00087 blendStateSourceAlpha, 00088 blendStateInverseSourceAlpha, 00089 blendStateSourceAlphaSaturate, 00090 blendStateDestinationColor, 00091 blendStateInverseDestinationColor, 00092 blendStateDestinationAlpha, 00093 blendStateInverseDestinationAlpha, 00094 blendStateMax, 00095 }; 00096 00097 /** 00098 * ブレンドステートから文字列への変換 00099 * @param blendState ブレンドステート 00100 * @return ブレンドステート文字列 00101 */ 00102 static const String& blendStateToString(BlendState blendState); 00103 00104 /** 00105 * 文字列からブレンドステートへの変換 00106 * @param blendStateString ブレンドステート文字列 00107 * @return ブレンドステート 00108 */ 00109 static BlendState blendStateFromString(const String& blendStateString); 00110 00111 //-------------------------------------------------------------------------- 00112 // 生成、破棄 00113 //-------------------------------------------------------------------------- 00114 /** 00115 * コンストラクタ 00116 */ 00117 BlendSpriteState(); 00118 00119 /** 00120 * コンストラクタ 00121 * @param blendMode ブレンドモード 00122 * @param blendSource ブレンドソース 00123 * @param blendDestination ブレンドデスティネーション 00124 */ 00125 BlendSpriteState(BlendMode blendMode, 00126 BlendState blendSource, BlendState blendDestination); 00127 00128 /** 00129 * デストラクタ 00130 */ 00131 virtual ~BlendSpriteState(); 00132 00133 //-------------------------------------------------------------------------- 00134 // デフォルトステート 00135 //-------------------------------------------------------------------------- 00136 /** 00137 * デフォルトステートの取得 00138 * @return デフォルトステート 00139 */ 00140 virtual const SpriteRequest* getDefaultState() const{ 00141 return &defaultState; 00142 } 00143 00144 //-------------------------------------------------------------------------- 00145 // 描画 00146 //-------------------------------------------------------------------------- 00147 /** 00148 * 適用 00149 * @param renderState レンダーステート 00150 */ 00151 virtual void apply(SpriteRenderState* renderState); 00152 00153 //-------------------------------------------------------------------------- 00154 // ブレンド 00155 //-------------------------------------------------------------------------- 00156 /** 00157 * ブレンドモードの設定 00158 * @param blendMode ブレンドモード 00159 */ 00160 virtual void setBlendMode(BlendMode blendMode){ 00161 Assert((blendMode >= 0) && (blendMode < blendModeMax)); 00162 blendMode_ = blendMode; 00163 } 00164 00165 /** 00166 * ブレンドモードの取得 00167 * @return ブレンドモード 00168 */ 00169 virtual BlendMode getBlendMode() const{ return blendMode_; } 00170 00171 /** 00172 * ブレンドが有効か 00173 * @return ブレンドが有効ならtrue 00174 */ 00175 virtual bool isBlendEnabled() const{ 00176 return (blendMode_ != blendModeDisable); 00177 } 00178 00179 //-------------------------------------------------------------------------- 00180 /** 00181 * ブレンドソースの設定 00182 * @param blendSource ブレンドソース 00183 */ 00184 virtual void setBlendSource(BlendState blendSource){ 00185 Assert((blendSource >= 0) && (blendSource < blendStateMax)); 00186 blendSource_ = blendSource; 00187 } 00188 00189 /** 00190 * ブレンドソースの取得 00191 * @return ブレンドソース 00192 */ 00193 virtual BlendState getBlendSource() const{ return blendSource_; } 00194 00195 //-------------------------------------------------------------------------- 00196 /** 00197 * ブレンドデスティネーションの設定 00198 * @param blendDestination ブレンドデスティネーション 00199 */ 00200 virtual void setBlendDestination(BlendState blendDestination){ 00201 Assert((blendDestination >= 0) && (blendDestination < blendStateMax)); 00202 blendDestination_ = blendDestination; 00203 } 00204 00205 /** 00206 * ブレンドデスティネーションの取得 00207 * @return ブレンドデスティネーション 00208 */ 00209 virtual BlendState getBlendDestination() const{ return blendDestination_; } 00210 00211 private: 00212 //-------------------------------------------------------------------------- 00213 // ブレンドモード 00214 BlendMode blendMode_; 00215 // ブレンドソース 00216 BlendState blendSource_; 00217 // ブレンドデスティネーション 00218 BlendState blendDestination_; 00219 00220 // ブレンドモード文字列テーブル 00221 static const String blendModeStringTable[]; 00222 // ブレンドステート文字列テーブル 00223 static const String blendStateStringTable[]; 00224 00225 }; 00226 00227 //------------------------------------------------------------------------------ 00228 } // End of namespace Lamp 00229 #endif // End of BLEND_SPRITE_STATE_H_ 00230 //------------------------------------------------------------------------------