Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

Picture.h

Go to the documentation of this file.
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 PICTURE_H_
00026 #define PICTURE_H_
00027 
00028 #include <Graphics/Scene/SceneObject.h>
00029 #include <Graphics/System/GraphicsDeviceObjectHolder.h>
00030 #include <Core/Container/ArrayList.h>
00031 
00032 namespace Lamp{
00033 
00034 class Texture;
00035 class PictureRGB8;
00036 class PictureRGBA8;
00037 
00038 //------------------------------------------------------------------------------
00039 /**
00040  * ピクチャ
00041  */
00042 class Picture : public SceneObject , public GraphicsDeviceObjectHolder{
00043 friend class SceneObjectManagerTemplate<Picture>;
00044 friend class PictureManager;
00045 friend class Texture;
00046 friend class SurfaceTexture;
00047 public:
00048     //--------------------------------------------------------------------------
00049     /**
00050      * リファレンスカウントの取得
00051      * @return リファレンスカウント
00052      */
00053     virtual int getReferenceCount() const{ return parents_.getCount(); }
00054 
00055     //--------------------------------------------------------------------------
00056     /**
00057      * コピー
00058      * @return コピーされたピクチャ
00059      */
00060     virtual Picture* copy() const = 0;
00061 
00062     /**
00063      * 破棄
00064      * @param picture 破棄するピクチャ
00065      * @return 破棄したオブジェクト数
00066      */
00067     static int destroy(Picture* picture);
00068 
00069     //--------------------------------------------------------------------------
00070     /**
00071      * ステート変更フラグを立てる
00072      */
00073     virtual void stateChanged();
00074 
00075     //--------------------------------------------------------------------------
00076     /**
00077      * 親のサイズ取得
00078      * @return 親のサイズ
00079      */
00080     virtual int getParentCount() const{ return parents_.getCount(); }
00081 
00082     /**
00083      * 親の取得
00084      * @param index 親のインデックス
00085      * @return 親
00086      */
00087     virtual Texture* getParent(int index) const{
00088         Assert(index >= 0);
00089         Assert(index < getParentCount());
00090         return parents_.get(index);
00091     }
00092 
00093     //--------------------------------------------------------------------------
00094     /**
00095      * パスの設定
00096      * @param path パス
00097      */
00098     virtual void setPath(const String& path){
00099         path_ = path;
00100         stateChanged();
00101     }
00102 
00103     /**
00104      * パスの取得
00105      * @return パス
00106      */
00107     virtual const String& getPath() const{ return path_; }
00108 
00109     //--------------------------------------------------------------------------
00110     /**
00111      * サイズの設定
00112      * @param size サイズ
00113      */
00114     virtual void setSize(const DimensionI& size){
00115         size_ = size;
00116         stateChanged();
00117     }
00118 
00119     /**
00120      * サイズの取得
00121      * @return サイズ
00122      */
00123     virtual const DimensionI& getSize() const{ return size_; }
00124 
00125     //--------------------------------------------------------------------------
00126     /**
00127      * デバイスオブジェクトの初期化
00128      * @return 成功したらtrueを返す
00129      */
00130     virtual bool initializeGraphicsDeviceObjects(){ return true; }
00131 
00132     /**
00133      * デバイスオブジェクトの削除
00134      */
00135     virtual void deleteGraphicsDeviceObjects(){}
00136 
00137     /**
00138      * デバイスオブジェクトのリストア
00139      * @return 成功したらtrueを返す
00140      */
00141     virtual bool restoreGraphicsDeviceObjects(){ return true; }
00142 
00143     /**
00144      * デバイスオブジェクトの無効化
00145      */
00146     virtual void invalidateGraphicsDeviceObjects(){}
00147 
00148     //--------------------------------------------------------------------------
00149     // RTTI
00150     //--------------------------------------------------------------------------
00151     /**
00152      * ピクチャかどうか
00153      * @return ピクチャならtrue
00154      */
00155     virtual bool isPicture() const{ return true; }
00156 
00157     //--------------------------------------------------------------------------
00158     /**
00159      * RGB8ビットピクチャかどうか
00160      * @return RGB8ビットピクチャならtrue
00161      */
00162     virtual bool isPictureRGB8() const{ return false; }
00163 
00164     /**
00165      * RGB8ビットピクチャへのキャスト
00166      * @return RGB8ビットピクチャ。型が違えばNULLを返す。
00167      */
00168     virtual PictureRGB8* castPictureRGB8() const{
00169         if(isPictureRGB8()){ return (PictureRGB8*)this; }
00170         return NULL;
00171     }
00172 
00173     //--------------------------------------------------------------------------
00174     /**
00175      * RGBA8ビットピクチャかどうか
00176      * @return RGBA8ビットピクチャならtrue
00177      */
00178     virtual bool isPictureRGBA8() const{ return false; }
00179 
00180     /**
00181      * RGBA8ビットピクチャへのキャスト
00182      * @return RGBA8ビットピクチャ。型が違えばNULLを返す。
00183      */
00184     virtual PictureRGBA8* castPictureRGBA8() const{
00185         if(isPictureRGBA8()){ return (PictureRGBA8*)this; }
00186         return NULL;
00187     }
00188 
00189     //--------------------------------------------------------------------------
00190 protected:
00191     /**
00192      * コンストラクタ
00193      * @param name 名前
00194      * @param scene シーン
00195      */
00196     Picture(const String& name, Scene* scene);
00197 
00198     /**
00199      * デストラクタ
00200      */
00201     virtual ~Picture();
00202 
00203     /**
00204      * ピクチャの値コピー
00205      * @param destination コピー先ピクチャ
00206      */
00207     virtual void copyPictureValue(Picture* destination) const;
00208 
00209     /**
00210      * 参照の追加
00211      * @param parent 親
00212      * @return 参照カウント
00213      */
00214     virtual int addReference(Texture* parent){
00215         parents_.add(parent);
00216         return getParentCount();
00217     }
00218 
00219     /**
00220      * 参照の削除
00221      * @param parent 親
00222      * @return 参照カウント
00223      */
00224     virtual int removeReference(Texture* parent){
00225         parents_.removeByValue(parent);
00226         return getParentCount();
00227     }
00228 
00229     /**
00230      * D3Dテクスチャの取得
00231      * @return D3Dテクスチャの取得
00232      */
00233     virtual Direct3DTexture* getD3DTexture() = 0;
00234 
00235     //--------------------------------------------------------------------------
00236 private:
00237     // 親配列
00238     ArrayList<Texture*> parents_;
00239     // パス
00240     String path_;
00241     // サイズ
00242     DimensionI size_;
00243 
00244 };
00245 
00246 //------------------------------------------------------------------------------
00247 } // End of namespace Lamp
00248 #endif // End of PICTURE_H_
00249 //------------------------------------------------------------------------------
00250 

Generated on Wed Mar 16 10:29:33 2005 for Lamp by doxygen 1.3.2