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 SPRITE_PICTURE_H_ 00026 #define SPRITE_PICTURE_H_ 00027 00028 #include <Graphics/System/GraphicsDeviceObjectHolder.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * スプライトピクチャ 00035 */ 00036 class SpritePicture : public GraphicsDeviceObjectHolder{ 00037 friend class SpriteRenderState; 00038 friend class Sprite; 00039 public: 00040 //-------------------------------------------------------------------------- 00041 // 生成、破棄 00042 //-------------------------------------------------------------------------- 00043 /** 00044 * コンストラクタ 00045 */ 00046 SpritePicture(); 00047 00048 /** 00049 * デストラクタ 00050 */ 00051 virtual ~SpritePicture(); 00052 00053 //-------------------------------------------------------------------------- 00054 // サイズ 00055 //-------------------------------------------------------------------------- 00056 /** 00057 * サイズの設定 00058 * @param size サイズ 00059 */ 00060 virtual void setSize(const DimensionI& size){ 00061 Assert((size.width > 0) && (size.height > 0)); 00062 size_ = size; 00063 } 00064 00065 /** 00066 * サイズの取得 00067 * @return サイズ 00068 */ 00069 virtual const DimensionI& getSize() const{ return size_; } 00070 00071 //-------------------------------------------------------------------------- 00072 // 参照カウンタ 00073 //-------------------------------------------------------------------------- 00074 /** 00075 * 参照カウントの取得 00076 */ 00077 virtual int getReferenceCount() const{ return referenceCount_; } 00078 00079 //-------------------------------------------------------------------------- 00080 // グラフィックデバイスオブジェクト 00081 //-------------------------------------------------------------------------- 00082 /** 00083 * デバイスオブジェクトの初期化 00084 * @return 成功したらtrueを返す 00085 */ 00086 virtual bool initializeGraphicsDeviceObjects(){ return true; } 00087 00088 /** 00089 * デバイスオブジェクトの削除 00090 */ 00091 virtual void deleteGraphicsDeviceObjects(){ SafeRelease(d3dTexture_); } 00092 00093 /** 00094 * デバイスオブジェクトのリストア 00095 * @return 成功したらtrueを返す 00096 */ 00097 virtual bool restoreGraphicsDeviceObjects(){ return true; } 00098 00099 /** 00100 * デバイスオブジェクトの無効化 00101 */ 00102 virtual void invalidateGraphicsDeviceObjects(){} 00103 00104 protected: 00105 //-------------------------------------------------------------------------- 00106 // Direct3Dテクスチャ 00107 //-------------------------------------------------------------------------- 00108 /** 00109 * D3Dテクスチャの取得 00110 * @return D3Dテクスチャの取得 00111 */ 00112 virtual Direct3DTexture* getD3DTexture(); 00113 00114 /** 00115 * D3Dテクスチャの設定 00116 * @param d3dTexture D3Dテクスチャ 00117 */ 00118 virtual void setD3DTexture(Direct3DTexture* d3dTexture){ 00119 SafeRelease(d3dTexture_); 00120 d3dTexture_ = d3dTexture; 00121 } 00122 00123 /** 00124 * D3Dテクスチャのコンパイル 00125 * @return 成功すればtrueを返す 00126 */ 00127 virtual bool compileD3DTexture() = 0; 00128 00129 //-------------------------------------------------------------------------- 00130 // 参照カウンタ 00131 //-------------------------------------------------------------------------- 00132 /** 00133 * 参照の追加 00134 * @return 参照カウント 00135 */ 00136 virtual int addReference(){ 00137 referenceCount_++; 00138 return referenceCount_; 00139 } 00140 00141 /** 00142 * 参照の削除 00143 * @return 参照カウント 00144 */ 00145 virtual int removeReference(){ 00146 referenceCount_--; 00147 Assert(referenceCount_ >= 0); 00148 return referenceCount_; 00149 } 00150 00151 private: 00152 //-------------------------------------------------------------------------- 00153 // コピーコンストラクタの隠蔽 00154 SpritePicture(const SpritePicture& copy); 00155 00156 // 代入コピーの隠蔽 00157 void operator =(const SpritePicture& copy); 00158 00159 //-------------------------------------------------------------------------- 00160 // サイズ 00161 DimensionI size_; 00162 // Direct3Dテクスチャ 00163 Direct3DTexture* d3dTexture_; 00164 // 参照カウント 00165 int referenceCount_; 00166 00167 }; 00168 00169 //------------------------------------------------------------------------------ 00170 } // End of namespace Lamp 00171 #endif // End of SPRITE_PICTURE_H_ 00172 //------------------------------------------------------------------------------